In the Sugar UI we have currently the following behavior for Palettes: when you left click on a an icon the primary action is executed, if you hover over an icon the Palette with primary and secondary options is displayed (with a small delay to prevent Palettes from popping up undesiredly when moving the mouse over icons fast) and when doing a right click on an icon the Palette with the options is displayed immediately. A good example are the activity icons in the Home View where the above logic applies cleanly.
On touchscreen devices where we only navigate with fingers and where no mouse is provided we do not have the right click option. A lot of the UIs for touchscreen devices do enter this path with a press and hold action. Currently the GTK+ developers are designing and implementing this behavior for GTK+ and the API is discussed. There is as well a GTK+ branch for multitouch that does implment the current design.
I did compile the branch on Fedora rawhide and run it on my Wetab. I did a small python example to see how it feels. Basically you connect to a signal ‘press-and-hold me’ and in the callback you get detailed information about the action. In the callback you can decide whether and how you want to handle the event. An animation is shown while the finger is hold down to emphasize that something is going on.
from gi.repository import Gtk
from gi.repository import Gdk
def __destroy_cb(widget, data=None):
def __press_and_hold(widget, device, action, x, y, data=None):
if action == Gtk.PressAndHoldAction.QUERY:
elif action == Gtk.PressAndHoldAction.TRIGGER:
elif action == Gtk.PressAndHoldAction.CANCEL:
window = Gtk.Window()
window.set_title('Press and Hold')
button = Gtk.Button('press-and-hold me')
The animation can be disabled as well, if it is not desired by setting the ‘gtk-enable-animations’ property:
settings = Gtk.Settings.get_default()
As well you can theme the animation:
background-color: alpha (@bg_color, 0.5);
color: alpha (lighter (@selected_bg_color), 0.8);
All in all I like the proposed API and it feels straight forward. As well I think that having the animation will help the user experience. Looking forward that this great work will get merged!