Re: Key bindings

From: mitchell <mforal.n....at.gmail.com>
Date: Mon, 22 Feb 2010 17:51:38 -0800 (PST)

Brian,

> If I do this:
>
> keys['s('] = {function() if buffer.get_sel_text() ~= '' then
> m_editing.enclose("parens") end end}
>
> or this:
>
> keys['s('] = {function() if buffer.get_sel_text() == '' then return true
> else m_editing.enclose("parens") end end}
>
> it becomes impossible to insert a '(' character into the buffer. "return
> false" seems to be the only way to allow the event to be handled further.

You are correct, my mistake. Returning 'true' explicitly halts GTK
event propagation, not just ta's handler propagation. Returning
'false' halts ta's handler propagation, but GTK continues to process
the event (resulting in the correct character to be inserted).

Sorry for the noise,
Mitchell

>
> On 02/03/10 19:41, mitchell wrote:
>
> > Brian,
>
> >> The "return false" part of the function there signals to Textadept that
> >> it should let other input handlers handle the event.
>
> > This is not the case (at least it shouldn't be!). According to LuaDoc:
>
> > Events can be given any number of arguments. These arguments will be
> > passed to the event's handler functions. If a handler returns either
> > true or false explicitly, all subsequent handlers are not called. This
> > is useful if you want to stop the propagation of an event like a
> > keypress.
>
> > Mitchell
>
> >> If there's a
> >> selection, the selection is enclosed in brackets, otherwise it just goes
> >> on to add the character. (You may have noticed that I modified the
> >> "enclose_in" function to do a few extra things such as C-style /* */
> >> comments.)
>
> >> On 02/03/10 09:15, Rob wrote:
>
> >>> Thanks for the update and sharing the key commands.
> >>> Brian, what is the expected output if nothing is selected and you type
> >>> for example a bracket? Did you disable the automatic closing of
> >>> quotes, brackets etc.?
Received on Mon 22 Feb 2010 - 20:51:38 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:39:03 EST