TAB Order
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
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
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...!
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...!
> 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?
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?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.

Actually, I use PureVision and I create/destroy too many gadgets.
Thanks in advance
PB 6.21 beta, PureVision User
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
Why don't you the change tab order in PureVision just before generating the code ?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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
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.gnozal wrote:Why don't you the change tab order in PureVision just before generating the code ?
(Sorry for 'google translation'

Last edited by zikitrake on Fri Feb 16, 2007 3:17 pm, edited 1 time in total.
PB 6.21 beta, PureVision User
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
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?
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?
oh... and have a nice day.
Hi, SortGadgetTabs lib makes an ArrayList of all gadget and sort it by X-Y position (GetGadgetX(), GetGadgetY()) and later make a:of all elements
Code: Select all
SetWindowPos_(GadgetN, GadgetNPrevious, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
PB 6.21 beta, PureVision User
Isn't that the same exact method I used in my code ^above ^ Why the need for a libzikitrake wrote:Hi, SortGadgetTabs lib makes an ArrayList of all gadget and sort it by X-Y position (GetGadgetX(), GetGadgetY()) and later make a:of all elementsCode: Select all
SetWindowPos_(GadgetN, GadgetNPrevious, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)

What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1



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.
PB 6.21 beta, PureVision User
Not to worry zikitrake, I'm not bothered by your lib.zikitrake wrote:The last thing that I would like is to bother someone.

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.

What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1