1. RE: navigating across groups

Hi George,

I don't know if this is the proper way to do this or if it's even 
exactly what you're wanting to do, but the only way I've been able to 
get from one group to another without using the mouse is by setting 
focus to a control on the next group.  Either by trapping a key or when 
the last field on the current group loses focus.  It seems that I had 
some problems doing this with combos though.  Hopefully someone will 
have a better solution.

Virtual B

George Walters wrote:
> I have created a panel which has several 'groups' containing items such 
> as
> radio buttons, edittext fields, etc. and have a question. Are there any
> keystrokes (rather that mouse clicks) to 'tab' one from one group to the
> next group?
> 
> 
> george
> 
> 
>

new topic     » topic index » view message » categorize

2. RE: navigating across groups

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C2173E.5F9AD8F0
 charset=iso-8859-1

> -----Original Message-----
> From: George Walters [mailto:gwalters at sc.rr.com]
> Subject: navigating across groups
> 
> 
> 
> I have created a panel which has several 'groups' containing 
> items such as
> radio buttons, edittext fields, etc. and have a question. Are 
> there any
> keystrokes (rather that mouse clicks) to 'tab' one from one 
> group to the
> next group?
> 

Hi George,
assuming you are talking about win32lib, there is nothing built-in to the
library that does this for you. The whole issue of tabbing is one I'd like
to revisit in a future release. However, for the moment, you will need to
detect the keystoke you wish to use as a group-tab (eg. Ctrl-Shift-TAB) and
set focus to a control inside the 'next' group.

Here is one example of how you could do it (sorry for the lengthy post but
attachments don't come thru the web interface)...

------------------------------------------------
-- grouptab.exw   Version: 1.0
--
-- A Demo of how to do Group Tabbing.
--  This will cause focus to shift to the control that last had focus
--  in the next Group when Shift-Ctrl-Tab is pressed.
------------------------------------------------
without warning
include win32lib.ew
object VOID

------------------------------------------------
-- Controls IDs
------------------------------------------------
integer MainWin    
integer SB
integer Group1, C11, C12
integer Group2, C21, C22, C23
integer Group3, C31, C32, C33, C34
integer Group11, C111, C112
integer BT1, BT2, BT3
                   
sequence Groups Groups = {}          
sequence GroupCtrls GroupCtrls = {}
-----------------------------------------------
-- Event Handlers
------------------------------------------------

integer vTabState vTabState = -1
------------------------------------------------
procedure Event_Screen(integer self, integer event, sequence parms)
------------------------------------------------
-- This gets invoked for every event that the application receives.
-- However, we are only interested in KEYDOWN and KEYUP events. Some of 
-- these we wish to use and prevent Windows from seeing them.

    integer nextgroup              
    sequence nextcid
    sequence lKeyState

    if parms[1] = WM_KEYDOWN then
        if parms[2] = VK_TAB then
            -- The TAB key has just been pressed.
            lKeyState = and_bits({w32Func( xGetKeyState, {VK_CONTROL}),
                                  w32Func( xGetKeyState, {VK_SHIFT}  )},
#80) != 0
            -- Only to group tabbing if both Shift and Ctrl are down.
            if equal(lKeyState, {1,1}) then
                -- Set a default group in case the event happens to a
control
                -- that is not in any group.
                nextgroup = 1 
                for i = 1 to length(GroupCtrls) do
                    if find(self, GroupCtrls[i]) then
                        nextgroup = i+1
                        exit
                    end if
                end for
                if nextgroup > length(GroupCtrls) then
                    nextgroup = 1
                end if
                nextcid = getUserProperty(Groups[nextgroup], "infocus")
                setFocus(nextcid[1]) 
                -- Indicate that I just swollowed the TAB Down event, so
                -- that I can also hide the related TAB Up event.
                vTabState = 1            
                -- Hide this TAB press from Windows.
                returnValue(0)
                return
                
            end if
        end if            
    elsif parms[1] = WM_KEYUP and parms[2] = VK_TAB then
        if vTabState = 1 then        
            vTabState = -1
            -- Hide this KEYUP press from Windows.
            returnValue(0)
        end if
    end if
end procedure

------------------------------------------------
procedure GotFocus_Box(integer self, integer event, sequence parms)
------------------------------------------------
-- Remember which control has currently got focus in each group.
    integer lGroup
    
    for i = 1 to length(GroupCtrls) do
        if find(self, GroupCtrls[i]) then
            setUserProperty( Groups[i], "infocus", self)
            return
        end if
    end for
end procedure

------------------------------------------------
procedure Activate_MainWin(integer self, integer event, sequence parms)
------------------------------------------------       

    -- Set the initial focus.
    setFocus(BT1)
        
end procedure


------------------------------------------------
procedure GetKids(integer pParent, integer pIndx)
------------------------------------------------
-- This recursively builds a complete list of each group
-- and their child controls.
    sequence lKids
    
    lKids = findChildren(pParent)
    for i = 1 to length(lKids) do
        if lKids[i][2] = Group then
            Groups &= lKids[i][1]
            GroupCtrls &= {{}}
            GetKids( lKids[i][1], length(Groups) )
        else
            GroupCtrls[pIndx] &= lKids[i][1]
        end if
    end for              
end procedure

------------------------------------------------
-- Application Initiation
------------------------------------------------
function AppInit()
    integer lRC
    sequence lKids
    
    lRC = 0
    
    MainWin = createEx(Window, "Group Tabbing Demo (Ctrl-Shift-TAB)", 0, 0,
0, 600, 450, 0, 0)
    SB      = createEx(StatusBar, "", MainWin, 0, 0, 0, 0, 0, 0)
    
    Group1 = createEx( Group , "Group 1", MainWin,  5,  5, 170, 350, 0, 0) 
    C11    = createEx( EditText,      "",  Group1,  5, 25, 100,  35, 0, 0)
    C12    = createEx( EditText,      "",  Group1,  5, 75, 100,  35, 0, 0)
    Group11 = createEx( Group, "Group 11", Group1, 15,125, 100, 200, 0, 0)
    C111    = createEx( EditText,     "", Group11,  5, 25,  85,  35, 0, 0)
    C112    = createEx( EditText,     "", Group11,  5, 75,  85,  35, 0, 0)
    
    Group2 = createEx( Group , "Group 2", MainWin,185,  5, 170, 350, 0, 0)
    C21    = createEx( EditText,      "",  Group2,  5, 25, 100,  35, 0, 0)
    C22    = createEx( EditText,      "",  Group2,  5, 75, 100,  35, 0, 0)
    C23    = createEx( EditText,      "",  Group2,  5,125, 100,  35, 0, 0)
    
    Group3 = createEx( Group , "Group 3", MainWin,365,  5, 170, 350, 0, 0)
    C31    = createEx( EditText,      "",  Group3,  5, 25, 100,  35, 0, 0)
    C32    = createEx( EditText,      "",  Group3,  5, 75, 100,  35, 0, 0)
    C33    = createEx( EditText,      "",  Group3,  5,125, 100,  35, 0, 0)
    C34    = createEx( EditText,      "",  Group3,  5,175, 100,  35, 0, 0)
                                                               
    BT1    = createEx( Button,    "Btn1", MainWin,550,  5,  40,  25, 0, 0)
    BT2    = createEx( Button,    "Btn2", MainWin,550, 55,  40,  25, 0, 0)
    BT3    = createEx( Button,    "Btn3", MainWin,550,105,  40,  25, 0, 0)
    
    -- We treat the main window as a pseudo group.
    Groups = {MainWin}
    GroupCtrls = {{}}
    GetKids(MainWin, 1)

    -- Link in the event handlers.   
    setHandler(Screen, w32HEvent, routine_id("Event_Screen"))
    setHandler(MainWin, w32HActivate, routine_id("Activate_MainWin"))    
    for i = 1 to length(GroupCtrls) do
        -- For each group, create a new property to hold which child
        -- control has focus within the group.
        defineUserProperty( Groups[i], "infocus", 0)
        
        for j = 1 to length(GroupCtrls[i]) do
            if j = 1 then
                -- Initialise the new group property.
                setUserProperty(Groups[i], "infocus", GroupCtrls[i][j])
            end if                                                 
            -- Set handler to record focus event.
            setHandler(GroupCtrls[i][j], w32HGotFocus,
routine_id("GotFocus_Box"))
        end for
    end for
        
    return lRC
end function    
        
if AppInit() = 0 then
    WinMain( MainWin, Normal)
end if    
-----------
cheers,
Derek


==================================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en 
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht 
onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en 
de afzender direct te informeren door het bericht te retourneren. 
==================================================================
The information contained in this message may be confidential 
and is intended to be exclusively for the addressee. Should you 
receive this message unintentionally, please do not use the contents 
herein and notify the sender immediately by return e-mail.


==================================================================

------_=_NextPart_000_01C2173E.5F9AD8F0
Content-Type: application/ms-tnef

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu