Re: [code] [textadept] Hiding/closing the command entry

From: Mitchell <m.att.foicica.com>
Date: Thu, 14 Mar 2013 09:19:38 -0400 (Eastern Daylight Time)

Hi Chris,

On Thu, 14 Mar 2013, Chris Emerson wrote:

> Hi Mitchell,
>
> On Wed, Mar 13, 2013 at 10:33:20PM -0400, Mitchell wrote:
>> Unlike in GTK, when you call gui.command_entry.focus() in ncurses,
>> the command entry blocks for input so there is no way for control to
>> be passed back to Lua to programmatically close it. This is an
>> unfortunate platform limitation :(
>
> Ok. In practice I only really want to close it on ESC (which works) and on
> Enter once I've done something with the text.
>
> On Enter I seem to have two choices - return true from the
> COMMAND_ENTRY_COMMAND event handler so that nothing happens (it stays
> open), or not (the entry closes but an error buffer opens since the text
> isn't a valid command as far as command_entry is concerned).
>
> As a test I added this at the end of the KEY_ENTER case in c_keypress:
>
> setExitType((CDKENTRY *)object, KEY_ENTER);
>
> which did what I wanted, but would break everyone else's uses. Could this
> be done based on a flag set in gui.command_entry.focus()? That would make
> it work slightly more like the GTK case.

Thanks for the follow up. Try returning `false` from your
COMMAND_ENTRY_COMMAND handler. That should hide the command entry in
ncurses on KEY_ENTER.

If an event handler explicitly returns a boolean (either true or false, it
does not matter) then event propagation stops, subsequent handlers like
the Lua command handler is not run (so you won't see the error you
describe), and lL_event will return FALSE, allowing the entry to close.

Cheers,
Mitchell

-- 
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 Thu 14 Mar 2013 - 09:19:38 EDT

This archive was generated by hypermail 2.2.0 : Fri 15 Mar 2013 - 06:30:01 EDT