Page 1 of 1

How to trap Shift+Tab to select previous input field

Posted: Thu Jun 06, 2013 6:44 pm
by daryl
Hi Folks,

I've been searching on how to trap the shift+tab key sequence to navigate to the previous text input field, but am unable to find anything on it.
Is there a message that can be trapped? Along these same lines, is it possible to chain messages together so they might share similar actions?

Any help would be much appreciated.

Thanks,

Daryl

Re: How to trap Shift+Tab to select previous input field

Posted: Thu Jun 06, 2013 8:28 pm
by mwieder
Well, it's *supposed to work, but doesn't. I'm sure it worked in a previous LC build, but I don't have one handy right now.
Here's what works for me (assuming that your fields are numbered sequentially and start with 1 - adjust the code accordingly)

Placed in the card script so that all the fields can use it:

Code: Select all

on rawKeyDown pKeyCode
    local tNewTarget
    
    -- 65056 is the keycode for the shift-tab combination
    -- discovered experimentally
    if pKeyCode is 65056 then
        put the number of the target -1 into tNewTarget
        if tNewTarget > 0 then
            focus on field tNewTarget
        end if
    end if
    pass rawKeyDown
end rawKeyDown

Re: How to trap Shift+Tab to select previous input field

Posted: Thu Jun 06, 2013 9:45 pm
by bn
Daryl,

you could set the autoTab property of the fields to true in the properties inspector. Then you can tab and shift-tab through the fields in the order of their layer number.

Kind regards
Bernd

Re: How to trap Shift+Tab to select previous input field

Posted: Thu Jun 06, 2013 11:43 pm
by mwieder
Bernd- that's the way it's *supposed* to work, yes. But tab does the right thing, while shift-tab doesn't work correctly irrespective of the the autoTab setting.

Re: How to trap Shift+Tab to select previous input field

Posted: Thu Jun 06, 2013 11:48 pm
by bn
Mark,

that's funny, I tried before posting: LC version 6.0.2 on Mac OSX 10.6.8

6 fields on a card and I could tab forward and shift-tab backwards.

????
Kind regards
Bernd

Re: How to trap Shift+Tab to select previous input field

Posted: Fri Jun 07, 2013 12:12 am
by mwieder
@Bernd- Hmmm... I tried it, too. Both times before posting. LC 6.0.2-rc1 on linux. Interesting.

Re: How to trap Shift+Tab to select previous input field

Posted: Fri Jun 07, 2013 2:40 am
by mwieder
OK - just tried it on OSX and autoTab works the way it should.