Do not trigger events on EventIcons when button release is outside - #4863
The industry convention for mouse driven menu options is for them to be activated when two conditions are met: * a button down event occurs with the pointer inside the option, and; * a button up event occurs with the pointer inside the option. This issue was already solved on the PaletteMenuItem, but the EventIcon have the same problem. This change add a 'activate' event, that control that the two conditions are meet. The code in Sugar need use this event instead of button-release-event.
This commit is contained in:
		
							parent
							
								
									9fc5b49329
								
							
						
					
					
						commit
						a19cf9ed27
					
				| @ -557,6 +557,10 @@ class EventIcon(Gtk.EventBox): | |||||||
|     cursor-positioned palette invoker. |     cursor-positioned palette invoker. | ||||||
|     """ |     """ | ||||||
| 
 | 
 | ||||||
|  |     __gsignals__ = { | ||||||
|  |         'activate': (GObject.SignalFlags.RUN_FIRST, None, []), | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     __gtype_name__ = 'SugarEventIcon' |     __gtype_name__ = 'SugarEventIcon' | ||||||
| 
 | 
 | ||||||
|     def __init__(self, **kwargs): |     def __init__(self, **kwargs): | ||||||
| @ -569,6 +573,7 @@ class EventIcon(Gtk.EventBox): | |||||||
|         self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | |         self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | | ||||||
|                         Gdk.EventMask.TOUCH_MASK | |                         Gdk.EventMask.TOUCH_MASK | | ||||||
|                         Gdk.EventMask.BUTTON_RELEASE_MASK) |                         Gdk.EventMask.BUTTON_RELEASE_MASK) | ||||||
|  |         self.connect('button-release-event', self.__button_release_event_cb) | ||||||
|         for key, value in kwargs.iteritems(): |         for key, value in kwargs.iteritems(): | ||||||
|             self.set_property(key, value) |             self.set_property(key, value) | ||||||
| 
 | 
 | ||||||
| @ -756,6 +761,11 @@ class EventIcon(Gtk.EventBox): | |||||||
| 
 | 
 | ||||||
|         self.set_palette(Palette(text)) |         self.set_palette(Palette(text)) | ||||||
| 
 | 
 | ||||||
|  |     def __button_release_event_cb(self, icon, event): | ||||||
|  |         alloc = self.get_allocation() | ||||||
|  |         if 0 < event.x < alloc.width and 0 < event.y < alloc.height: | ||||||
|  |             self.emit('activate') | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| class CanvasIcon(EventIcon): | class CanvasIcon(EventIcon): | ||||||
|     """ |     """ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Gonzalo Odiard
						Gonzalo Odiard