RE: [code] [textadept] Dynamic Menus

From: John Hind <john.hind.att.zen.co.uk>
Date: Fri, 5 Oct 2012 09:42:51 +0100

> Why not hook into the `events.BUFFER_NEW` and `events.BUFFER_DELETED`,
> regenerate a "static" menu, and then call
> `_M.textadept.menu.set_menubar` or `gui.menubar = ...`? It sounds like
> your idea is to have a top-level menubar with no child menus, and when
> one of those menus are clicked, Lua would create and send the menu for
> display. I'm not sure if GTK would display such a submenu that doesn't
> exist until *after* its first menu item is clicked.

That approach would work for buffers which can only be created within
Textadept, but not for styles, for example. Also it could be inefficient
because menus are being created and replaced which may never be shown. I am
not familiar with GTK, so portability may be a showstopper, but this is
straightforward in Win32 API. The window gets a message immediately before a
menu or sub-menu is drawn. This message contains a menu handle which you can
use to add or delete menu items. My "Grunt" Windows Scripting system works
by having a dummy Win32 menu and emptying it out and re-populating it from a
Lua table each time it is about to be shown. But this may not be possible in
GTK (or on the other platforms).

Best, John.

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 05 Oct 2012 - 04:42:51 EDT

This archive was generated by hypermail 2.2.0 : Fri 05 Oct 2012 - 06:45:28 EDT