[ wxwindows-Bugs-1693273 ] Slider mouse events on OS X
SourceForge.net
noreply at sourceforge.net
Tue Apr 3 05:05:21 PDT 2007
Bugs item #1693273, was opened at 2007-04-02 19:01
Message generated for change (Comment added) made by msborg
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1693273&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMac specific
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Ed Leafe (msborg)
Assigned to: Stefan Csomor (csomor)
Summary: Slider mouse events on OS X
Initial Comment:
I've noticed that when using a slider on OS X, the EVT_LEFT_UP never gets triggered when the mouse is over the thumb control. However, if you click within the rectangular area of the control, but not along the slider "slot" (i.e., click on the control where it won't affect the thumb control), the event is triggered.
I've created a simple program that demonstrates this problem. I see both the down and up events on Windows, but on OS X, only the down events.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
import wx
class TestFrame(wx.Frame):
def __init__(self, parent, id):
super(TestFrame, self).__init__(parent=parent, id=id)
self.SetSize((300, 400))
pnl = wx.Panel(self)
self.slider = wx.Slider(pnl)
self.slider.SetPosition((50, 50))
self.slider.Bind(wx.EVT_LEFT_DOWN, self.onSliderLeftDown)
self.slider.Bind(wx.EVT_LEFT_UP, self.onSliderLeftUp)
def onSliderLeftDown(self, evt):
print "SLIDER LEFT DOWN"
evt.Skip()
def onSliderLeftUp(self, evt):
print "SLIDER LEFT UP"
evt.Skip()
if __name__ == '__main__':
app = wx.PySimpleApp()
frm = TestFrame(None, -1)
frm.Show()
app.MainLoop()
----------------------------------------------------------------------
>Comment By: Ed Leafe (msborg)
Date: 2007-04-03 08:05
Message:
Logged In: YES
user_id=501059
Originator: YES
The problem that I was trying to solve was that as the thumb control is
dragged, wx.EVT_SLIDER events are continuously emitted, and binding
non-trivial code to that really bogged down responsiveness. I wanted to be
able to only bind to the thumb release when it was dragged, but also
respond to keyboard-type movement. Tracking the mouse up/down events worked
on Gtk and Windows, but failed on OS X, so Robin suggested that I file this
as a bug report. I have already come up with a workaround that uses
wx.GetMouseState() to independently track the mouse status.
Also, mouse up events *are* sent by a slider on OS X if you click on the
non-"slot" areas. So in that sense at least, the behavior does seem
inconsistent.
----------------------------------------------------------------------
Comment By: Stefan Csomor (csomor)
Date: 2007-04-03 07:53
Message:
Logged In: YES
user_id=81467
Originator: NO
sorry for not being clear : on OS X a mouse down over a control leads to
that control tracking the mouse until a mouse up occurs. Therefore a mouse
up will not be sent.
Now the next part is true for every platform : always use the highest API
level that is available, in order to hide your code from platform
differences, eg don't display a context-menu on a right mouse up event, but
do so at a context menu event (because on the mac the context menu is
triggered by a ctrl-mouse down). A slider as I explained exposes the scroll
events family and a command event. So if you are interested in the value
change, please do a ...Bind(wx.EVT_SLIDER,... this will be triggered
whether the value change is done by mouse or by keyboard or by assistive
voice technology ...
Best,
Stefan
----------------------------------------------------------------------
Comment By: Ed Leafe (msborg)
Date: 2007-04-03 07:10
Message:
Logged In: YES
user_id=501059
Originator: YES
I'm not sure that I understand your reply. Are you saying that this is a
*feature*, and will not be changed? It always sucks to have to bracket code
to work differently depending on platform.
----------------------------------------------------------------------
Comment By: Stefan Csomor (csomor)
Date: 2007-04-03 00:22
Message:
Logged In: YES
user_id=81467
Originator: NO
Hi
yes, on OS X the mouse up event when dragging always belongs to the
control and is not exposed, you always should try to catch the
highest-level event exposed by a control, in the case of a slider you have
always two events that are triggered, first the group of scroll events
depending what happened, and then a command event
(wxEVT_COMMAND_SLIDER_UPDATED) that matches wx.EVT_SLIDER for wxPython
informing you that the value changed.
Best,
Stefan
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1693273&group_id=9863
More information about the wx-dev
mailing list