How to trap Shift+Tab to select previous input field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

How to trap Shift+Tab to select previous input field

Post 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
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post 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
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

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

Post 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
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post 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.
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

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

Post 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
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post by mwieder »

@Bernd- Hmmm... I tried it, too. Both times before posting. LC 6.0.2-rc1 on linux. Interesting.
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

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

Post by mwieder »

OK - just tried it on OSX and autoTab works the way it should.
Post Reply