Re: Tabbing problem in Child Window
I am using following code for nagivation -
(picked up & modified from win32lib example for Group Tabbing)
--#============================================================================================
--#Move to next or previous control in the screen on pressing Enter/Down or Up
key respectively.
--#============================================================================================
------------------------------------------------
procedure GotFocus_Box(integer self, integer event, sequence params)
------------------------------------------------
-- Remember which control has currently got focus in each group.
setUserProperty( findParent(self), "infocus", self)
end procedure
-- Set initial focus and handlers for all children inside groups.
------------------------------------------------
global procedure SetGroupNavigator(integer pID, integer Set)
------------------------------------------------
sequence lKids
integer lSet
lKids = getControlInfo(pID, CONTROLINFO_group)
lSet = 0
for i = 1 to length(lKids) do
if getControlInfo(lKids[i], CONTROLINFO_type) != Group then
if lSet = 0 then
-- The first non-group child has initial focus.
if Set then
setUserProperty( pID, "infocus", lKids[i])
else
deleteUserProperty( pID, "infocus")
end if
lSet = 1
end if
if Set then
setHandler(lKids[i], w32HGotFocus, routine_id("GotFocus_Box"))
else
removeHandler(lKids[i], w32HGotFocus, routine_id("GotFocus_Box"))
end if
else
SetGroupNavigator(lKids[i], Set)
end if
end for
end procedure
procedure TrapNavigation(integer self, integer event, sequence params)--params
is ( atom scanCode, atom shift )
sequence checkLists, checkButns, checkEdits, idName, className
integer nextgroup, inc, lParent, lGrandParent, lMainWin, lEnd, lStart
object nextcid
sequence lKeyState, lKids
checkLists = {"ComboBox", "SysListView32", "SysTreeView32"}
checkEdits = {"Edit"}
checkButns = {"Button"}
if not (params[1] = VK_ENTER or params[1] = VK_RETURN or
params[1] = VK_DOWN or params[1] = VK_UP) then
return
end if
if params[1] = VK_DOWN or params[1] = VK_UP then
className = getClassName(self)
if find(className, checkLists) then -- normal processing for
Combo/List/TreeViews
return
end if
lParent = findParent(self)
lMainWin = findParentWindow(self)
lGrandParent = findParent(lParent)
if lGrandParent = 0 then
lGrandParent = lMainWin
end if
if params[1] = VK_DOWN then
-- Move to the focus item inside the next group on my level.
-- Get all my parent's siblings.
lKids = getControlInfo(lGrandParent, CONTROLINFO_group)
if lGrandParent = lParent then
lKids = lParent & lKids
end if
-- Find my parent in its sibling list
nextgroup = find(lParent, lKids)
-- Direction depends on the Shift key state.
if and_bits(params[2], ShiftMask) = 0 then
inc = 1
else
inc = -1
end if
if inc > 0 then
lEnd = length(lKids)
else
lEnd = 1
end if
lStart = nextgroup
nextcid = 0
while lStart != lEnd do
lStart += inc
if getControlInfo(lKids[lStart], CONTROLINFO_type) = Group then
nextcid = lKids[lStart]
exit
end if
end while
if nextcid = 0 then
lEnd = nextgroup
if lStart = 1 then
lStart = length(lKids) + 1
else
lStart = 0
end if
while lStart != lEnd do
lStart += inc
if getControlInfo(lKids[lStart], CONTROLINFO_type) = Group then
nextcid = lKids[lStart]
exit
end if
end while
end if
if nextcid != 0 then
nextcid = getUserProperty(nextcid, "infocus")
if length(nextcid) > 0 then
setFocus(nextcid[1])
end if
end if
elsif params[1] = VK_UP then
-- If my parent is a group, then move to my grandparent's focus item.
nextcid = getUserProperty(lGrandParent, "infocus")
if length(nextcid) > 0 then
setFocus(nextcid[1])
end if
end if
else
className = getClassName(self)
if find(className, checkLists) or
-- find(className, checkEdits) or
find(className, checkButns) then
if params[1] = VK_RETURN and and_bits(params[2], ShiftMask) = 0 then
tab_direction(self, 1)
end if
end if
end if
-- Hide this Key press from Windows.
returnValue(0)
return
end procedure
setHandler(Screen, w32HKeyDown, routine_id("TrapNavigation"))
--#============================================================================================
I suspect the portion at the end of TrapNagigation-
className = getClassName(self)
if find(className, checkLists) or
-- find(className, checkEdits) or
find(className, checkButns) then
if params[1] = VK_RETURN and and_bits(params[2], ShiftMask) = 0 then
tab_direction(self, 1)
end if
end if
is responsible for this behaviour, but otherwise how to move out of
ListView/TreeView with
ENTER key (or any other key)?
Regards,
Rad.
|
Not Categorized, Please Help
|
|