Hello Guest it is January 20, 2020, 11:59:31 AM

Author Topic: Bitmap buttons left up action  (Read 2638 times)

0 Members and 2 Guests are viewing this topic.

Bitmap buttons left up action
« on: June 21, 2016, 01:52:33 PM »
Hi everyone,

I have noticed that if I click and hold on a bitmap button and move the mouse off of the button before releasing then the left up action/script does not fire. I have tested this with a few bitmap buttons and this is the case for all of them but not the case for regular buttons. Does anyone else have this issue and if so, have you found a way around it (aside from replacing them with regular buttons)?

Thank You,
Zealot416

Offline DazTheGas

*
  •  752 752
  • DazTheGas
    • View Profile
Re: Bitmap buttons left up action
« Reply #1 on: June 21, 2016, 03:00:19 PM »
Buttons use a set of events to determine what to act on, these can be EVT_LEAVE_WINDOW, EVT_LEFT_DOWN, EVT_LEFT_UP, EVT_MIDDLE_DCLICK, EVT_MIDDLE_DOWN and loads more.

Its more than likely that the bitmap button class in mach4 has an event trigger for EVT_LEAVE_WINDOW which is good practice to set this to do nothing, giving the user the chance to abort the button press.

DazTheGas
Theres always time for a choccy biccy
Re: Bitmap buttons left up action
« Reply #2 on: June 21, 2016, 03:13:56 PM »
Right now I am using bitmap arrows for my jog controls. Since I never want Jog Off to be aborted, should i replace the arrows with normal buttons or do you know of a workaround?

Offline DazTheGas

*
  •  752 752
  • DazTheGas
    • View Profile
Re: Bitmap buttons left up action
« Reply #3 on: June 21, 2016, 03:53:44 PM »
Then on a case like that then not, the only work around i know would be to use a panel then inside the panel create a bitmap button and use the event codes to your likeing. you can create such things with formbuilder.

Example from my own screen might get you on track ;-)

Code: [Select]
local cstart_btn_dis = btn_path.."CStart_dis.png"
local cstart_btn_dwn = btn_path.."CStart_dwn.png"
local cstart_btn_up = btn_path.."CStart_up.png"
local cstart_btn_hov = btn_path.."CStart_hov.png"

Cont.cstart_btn = wx.wxBitmapButton( Cont.Panel, wx.wxID_ANY, wx.wxBitmap( cstart_btn_up, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(10,440), wx.wxDefaultSize, wx.wxBU_AUTODRAW + wx.wxNO_BORDER)
Cont.cstart_btn:SetBackgroundColour( wx.wxSystemSettings.GetColour( wx.wxSYS_COLOUR_ACTIVECAPTION ) )

Cont.cstart_btn:SetBitmapDisabled( wx.wxBitmap( cstart_btn_dis, wx.wxBITMAP_TYPE_ANY ) )
Cont.cstart_btn:SetBitmapSelected( wx.wxBitmap( cstart_btn_dwn, wx.wxBITMAP_TYPE_ANY ) )
Cont.cstart_btn:SetBitmapFocus( wx.wxBitmap( cstart_btn_up, wx.wxBITMAP_TYPE_ANY ) )
Cont.cstart_btn:SetBitmapHover( wx.wxBitmap( cstart_btn_hov, wx.wxBITMAP_TYPE_ANY ) )
Cont.cstart_btn:SetToolTip( "Cycle Start" )


Cont.cstart_btn:Connect( wx.wxEVT_LEFT_UP, function(event)
        mc.mcCntlCycleStart(inst);
Cont.main_gcode:SetFocus()
gcLine_timer:Start(100)
        event:Skip()
        end )

The code above is useing the EVT_LEFT_UP but you can add the EVT_LEFT_DOWN to start the jogging and then the EVT_LEFT_UP and EVT_LEAVE_WINDOW to stop the joggin.

DazTheGas
« Last Edit: June 21, 2016, 03:56:01 PM by DazTheGas »
Theres always time for a choccy biccy
Re: Bitmap buttons left up action
« Reply #4 on: June 21, 2016, 04:14:22 PM »
Cool. Thank you! :D
Re: Bitmap buttons left up action
« Reply #5 on: June 22, 2016, 02:07:08 PM »
Simple question, and maybe I'm missing something - why not use the "left down" action and/or script instead of "left up"?  If this is something that you are sure yo never want the user to change their mind and abort the action, then "left down" would execute as soon as they clicked.

Bob
Re: Bitmap buttons left up action
« Reply #6 on: June 22, 2016, 02:24:17 PM »
Left Down = starts jog
Left up = ends jog

the goal is to have the machine jog so long as the button is held down
Re: Bitmap buttons left up action
« Reply #7 on: June 22, 2016, 05:01:29 PM »
For some reason my code stops working after i edit the screen (even if i enter edit mode and then immediately exit it). It works perfectly fine at start up. Here is an abridged version of the code if anyone has any ideas.

Code: [Select]
local jog_btn_up ="blah"
local jog_btn_dn ="blah"
local jog_btn_lt ="blah"
local jog_btn_rt ="blah"

local panel = mcLuaPanelParent;
local window = panel:GetParent();
window:SetBackgroundColour(wx.wxColour(230, 230, 230));

local up_btn = wx.wxBitmapButton( childPanel, wx.wxID_ANY, wx.wxBitmap( jog_btn_up, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(100,0), wx.wxSize(60,70))
local dn_btn = wx.wxBitmapButton( childPanel, wx.wxID_ANY, wx.wxBitmap( jog_btn_dn, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(100,80), wx.wxSize(60,70))
local lt_btn = wx.wxBitmapButton( childPanel, wx.wxID_ANY, wx.wxBitmap( jog_btn_lt, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(20,45), wx.wxSize(70,60))
local rt_btn = wx.wxBitmapButton( childPanel, wx.wxID_ANY, wx.wxBitmap( jog_btn_rt, wx.wxBITMAP_TYPE_ANY ), wx.wxPoint(170,45), wx.wxSize(70,60))


up_btn:Connect(wx.wxEVT_LEFT_UP,
                function(event)
                   --blah
                end)
               
up_btn:Connect(wx.wxEVT_LEFT_DOWN,
                function(event)
                    --blah
                end)
up_btn:Connect(wx.wxEVT_LEAVE_WINDOW,
                function(event)
                    --blah         
                end)
dn_btn:Connect(wx.wxEVT_LEFT_UP,
                function(event)
                    --blah 
                end)
               
dn_btn:Connect(wx.wxEVT_LEFT_DOWN,
                function(event)
                    --blah
                end)
dn_btn:Connect(wx.wxEVT_LEAVE_WINDOW,
                function(event)
                    --blah          
                end)
rt_btn:Connect(wx.wxEVT_LEFT_UP,
                function(event)
                    --blah  
                end)
               
rt_btn:Connect(wx.wxEVT_LEFT_DOWN,
                function(event)
                    --blah
                end)
rt_btn:Connect(wx.wxEVT_LEAVE_WINDOW,
                function(event)
                   --blah             
                end)
lt_btn:Connect(wx.wxEVT_LEFT_UP,
                function(event)
                    --blah   
                end)
               
lt_btn:Connect(wx.wxEVT_LEFT_DOWN,
                function(event)
                   --blah
                end)
lt_btn:Connect(wx.wxEVT_LEAVE_WINDOW,
                function(event)
                    --blah            
                end)
               

Offline DazTheGas

*
  •  752 752
  • DazTheGas
    • View Profile
Re: Bitmap buttons left up action
« Reply #8 on: June 22, 2016, 06:24:26 PM »
At a quick glance you are trying to put the bitmaps onto "childPanel" that does not exist, try "panel" thats already declared ;-)

another thing thats ver good practice is to use "event:Skip()" within each event at the end

DazTheGas
Theres always time for a choccy biccy

Offline DazTheGas

*
  •  752 752
  • DazTheGas
    • View Profile
Re: Bitmap buttons left up action
« Reply #9 on: June 22, 2016, 06:30:56 PM »
Simple question, and maybe I'm missing something - why not use the "left down" action and/or script instead of "left up"?  If this is something that you are sure yo never want the user to change their mind and abort the action, then "left down" would execute as soon as they clicked.

Bob

Just a different scenario, unfortunately the bitmap button has a leave window event attached to it, so if used for jogging and you move the mouse off the button you will lose the button up event to turn jogging off.

DazTheGas
Theres always time for a choccy biccy