Page 1 of 2
TAB Order
Posted: Tue Mar 01, 2005 4:16 pm
by RichardL
Can any kindly assist and tell me how to set the TAB order for gadgets on a Windoze application?
Thanks...
Posted: Tue Mar 01, 2005 7:10 pm
by Sparkie
Here's something you can try.
Code: Select all
Enumeration
#ButtonGadget
#StringGadget
#CheckboxGadget
#OptionGadget
EndEnumeration
; --> How many gadgets to tab
gadgetsToTab = 4
; --> Array of gadget tab stops
Dim tabStop(gadgetsToTab-1)
; --> Set tab stop order
tabStop(0) = #StringGadget
tabStop(1) = #OptionGadget
tabStop(2) = #ButtonGadget
tabStop(3) = #CheckboxGadget
; --> Procedure to change z-order (tab stops)
Procedure GadgetTabOrder()
; Get zero based array size
tabCount = PeekL(@tabStop(0)-8)
For gad = 0 To tabCount - 1
If gad = 0
; First gadget is first tab stop
pos = #HWND_TOP
Else
; Remaining gadgets follow previous gadget
pos = GadgetID(previousGad)
EndIf
previousGad = tabStop(gad)
; --> Make the z-order change
SetWindowPos_(GadgetID(tabStop(gad)), pos, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
Next gad
EndProcedure
If OpenWindow(0, 0, 0, 220, 130, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Gadget Tab Order") And CreateGadgetList(WindowID(0))
ButtonGadget(#ButtonGadget, 10, 10, 200, 20, "Third Tab")
StringGadget(#StringGadget, 10, 40, 200, 20, "First Tab")
CheckBoxGadget(#CheckboxGadget, 10, 70, 200, 20, "Fouth Tab")
OptionGadget(#OptionGadget, 10, 100, 200, 20, "Second Tab")
GadgetTabOrder()
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
Posted: Tue Mar 01, 2005 7:36 pm
by Fred
In PureBasic, the tab orders are the order of the created gadgets on your window.
Posted: Tue Mar 01, 2005 8:00 pm
by Sparkie
My bad.
I was assuming RichardL wanted to
change his z-order.

Posted: Tue Mar 01, 2005 8:29 pm
by RichardL
Thanks Sparkie...
That is exactly what I needed. I am writing a fairly large application and create and destroy gadgets when various features are active or dormant; it is difficult to create the gadgets in the order I want to TAB them in, so now I can really sort things out.
An extra bonus from your example is that is seems that the size of an array can be found by a PeekL from the address of the zeroth element -8. It would be good to know what is at location @xxx(0)-4 and if there is anything else that can usefully be found... if the array type is available I could use this to make reasonable Insert and Delete functions that do not need to have the array type and size passed to them. I would like to do what the old GFA Basic did. (RIP old friend!). String arrays would be a challange...!
Posted: Sat Jul 02, 2005 3:49 am
by PB
> the tab orders are the order of the created gadgets on your window
I just had my first problem with this: I have a StringGadget, then a PanelGadget,
which in turn has two other gadgets on it. I want to give the focus to the second
gadget on the PanelGadget, whenever I press the TAB key on the StringGadget.
However, due to the order of created gadgets, I can't do it. I'll probably use
Sparkie's code for now, but perhaps there could be a flag added in a future
release of PureBasic to set the tab index, like in Visual Basic?
Posted: Thu Feb 15, 2007 9:05 pm
by zikitrake

Yes, It's a very old question, but.... are there any other mode to make this more easily?
Actually, I use PureVision and I create/destroy too many gadgets.
Thanks in advance
Posted: Fri Feb 16, 2007 9:00 am
by gnozal
zikitrake wrote:
Yes, It's a very old question, but.... are there any other mode to make this more easily?
Actually, I use PureVision and I create/destroy too many gadgets.
Thanks in advance
Why don't you the change tab order in PureVision just before generating the code ?
Posted: Fri Feb 16, 2007 9:44 am
by zikitrake
gnozal wrote:Why don't you the change tab order in PureVision just before generating the code ?
Yes, I can do it, but, when I am creating and destroying gadgets every time, it's very laborious to sort them. I was looking for a possible solution that does to myself more easily this work.
(Sorry for 'google translation'

)
Posted: Fri Feb 16, 2007 12:29 pm
by zikitrake
Posted: Fri Feb 16, 2007 3:05 pm
by Kaeru Gaman
iirc the TAB-order is an attribute of the object ...
it's not the same as the display-Z-order, wich isn't an object's attribute.
I understand that Z-order changes are not supportet, since the OS does not.
but why isn't changing the TAB-order supported?
is it a LINUX/MAC compatibility problem?
Posted: Fri Feb 16, 2007 3:13 pm
by zikitrake
Hi, SortGadgetTabs lib makes an ArrayList of all gadget and sort it by X-Y position (GetGadgetX(), GetGadgetY()) and later make a:
Code: Select all
SetWindowPos_(GadgetN, GadgetNPrevious, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
of all elements
Posted: Fri Feb 16, 2007 3:17 pm
by Sparkie
zikitrake wrote:Hi, SortGadgetTabs lib makes an ArrayList of all gadget and sort it by X-Y position (GetGadgetX(), GetGadgetY()) and later make a:
Code: Select all
SetWindowPos_(GadgetN, GadgetNPrevious, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
of all elements
Isn't that the same exact method I used in my code ^above ^ Why the need for a lib

Posted: Fri Feb 16, 2007 3:27 pm
by zikitrake

Yes, it's based in your code, but I modified to add Auto-count number of gadgets in any window.

The last thing that I would like is to bother someone.
My code is very chaotic for now, and I don't made any userlib until now, so I'm practicing with this code.
When I 'clean' the code it will be available with the lib.
Posted: Fri Feb 16, 2007 3:36 pm
by Sparkie
zikitrake wrote:The last thing that I would like is to bother someone.
Not to worry zikitrake, I'm not bothered by your lib.
I thought since you created a lib for all this that you may have been using a method that was different and simpler than what I was using. My curiosity had me wondering.
