RE: [code] [textadept] Dynamic Menus

From: Mitchell <>
Date: Sat, 6 Oct 2012 14:15:13 -0400 (Eastern Daylight Time)


On Fri, 5 Oct 2012, John Hind wrote:

>> Why not hook into the `events.BUFFER_NEW` and `events.BUFFER_DELETED`,
>> regenerate a "static" menu, and then call
>> `` 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).

Textadept uses GTK on all platforms, so if this is not possible in GTK
then it will not be possible at all in Textadept. The approach sounds
interesting, but because I am unfamiliar with it or where to even begin, I
will not be working on this. I am open to a patch, but I fear the
complexity will be rather high...

It is also worth noting that GTK integration with Mac OSX is still rather
new. I think you have to pass a GtkMenu or GtkMenuBar through an API that
generates a Cocoa menu so that may a problem for a cross-platform


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sat 06 Oct 2012 - 14:15:13 EDT

This archive was generated by hypermail 2.2.0 : Sun 07 Oct 2012 - 06:54:15 EDT