maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [M5] Help requested handling longpress in PyGTK (https://talk.maemo.org/showthread.php?t=97242)

Xagoln 2016-08-13 22:52

Help requested handling longpress in PyGTK
 
Hi all,
I know Qt is what everybody uses now, but I've started developing an app in PyGTK and am quite enjoying it.

However, I'm a bit stuck with trying to detect and handle longpresses on GTK TreeView rows.

I have cobbled together code from Modrana (thanks MartinK!) with examples from around the web (mostly PyGTK doco).

Basically I have connected the button-press-event and button-release-events for the treeview to two methods, and I've managed to get a context menu to display on a longpress on an item, but I'm having difficulty getting the menu to go away when the finger is lifted from the screen, and the menu also weirdly follows the finger around the screen as it moves.

Can anybody recommend other PyGTK apps I should inspect for examples of longpress popup menus, or spare some time to look at my code and give some guidance?

Xagoln 2016-08-19 09:12

Re: Help requested handling longpress in PyGTK
 
Okay, so I found what I needed in gPodder - specifically, the widget.tap_and_hold_setup(menu) method.

Code:

        menu = gtk.Menu()
        # "Emulate" hildon_gtk_menu_new (makes the menu larger
        # and easier to use with finger)
        menu.set_name('hildon-context-sensitive-menu')
        menu_item = gtk.MenuItem(_('Edit'))
        menu.append(menu_item)
        menu_item.connect('activate', self.activated, self.treeview)
        menu.show_all()
        treeview.tap_and_hold_setup(menu)



All times are GMT. The time now is 11:53.

vBulletin® Version 3.8.8