Can you disable the TAB jumping on a gadget?

Linux specific forum
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Can you disable the TAB jumping on a gadget?

Post by DoubleDutch »

You can do this on windows with:

Code: Select all

Procedure NoTabJump(gadget)
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    If IsGadget(gadget)
      style=GetWindowLong_(GadgetID(gadget),#GWL_STYLE)
      SetWindowLong_(GadgetID(gadget),#GWL_STYLE,style&((-1)-#WS_TABSTOP))
    EndIf
  CompilerEndIf
EndProcedure
But is there anyway to do the same in Linux?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

Check if this works for you:

Code: Select all

Procedure NoTabJump(gadget)
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    If IsGadget(gadget)
      style=GetWindowLong_(GadgetID(gadget),#GWL_STYLE)
      SetWindowLong_(GadgetID(gadget),#GWL_STYLE,style&((-1)-#WS_TABSTOP))
    EndIf
  CompilerEndIf
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    If IsGadget(gadget)
      *obj.GtkObject = GadgetID(gadget)
      *obj\flags = *obj\flags &~ (1 << 11)
    EndIf
  CompilerEndIf
EndProcedure
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

FloHimself: No, that doesn't seem to do it.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

oh, maybe I misunderstood. :(

Do you want
a) to hold the focus on one specific gadget
or
b) to exclude a gadget from getting the focus when "tab'ing"?

The code above should do b). Can't test your function on Windows...
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

b) Exclude the gadget from getting the focus when tabbing

- It does get the focus when tabbing though...

I'll have another go.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Strange, its working now???

But the focus doesn't go back to the 1st gadget on after the 2nd is tabbed - it gets stuck on the 2nd. You have to click the 1st again to select it.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

Strange! I've tested with this:

Code: Select all

Procedure NoTabJump(gadget)
  CompilerIf #PB_Compiler_OS = #PB_OS_Windows
    If IsGadget(gadget)
      style=GetWindowLong_(GadgetID(gadget),#GWL_STYLE)
      SetWindowLong_(GadgetID(gadget),#GWL_STYLE,style&((-1)-#WS_TABSTOP))
    EndIf
  CompilerEndIf
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    If IsGadget(gadget)
      *obj.GtkObject = GadgetID(gadget)
      *obj\flags = *obj\flags &~ (1 << 11)
    EndIf
  CompilerEndIf
EndProcedure

If OpenWindow(0, 0, 0, 222, 105, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
    ButtonGadget(0, 10, 10, 200, 0, "Button 0")
    ButtonGadget(1, 10, 40, 200, 0, "Button 1")
    ButtonGadget(2, 10, 70, 200, 0, "Button 2")
    NoTabJump(2)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
And get this:
http://www.youtube.com/watch?v=5O-6q_p_p-I
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It may depend on gadget type?

Does the latest Linux version of CutTheCosta tab stop at the end or start again at the beginning on your system?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

It stops at the end.
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It must be something to do with gadget type?
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

Maybe, but it should work on any Widget with a GTK_CAN_FOCUS flag.
You can check for that flag with this:

Code: Select all

Procedure CanGetFocus(gadget)
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    If IsGadget(gadget)
      *obj.GtkObject = GadgetID(gadget)
      If ((*obj\flags & (1 << 11)) <> 0)
        ProcedureReturn #True
      EndIf
    EndIf
  CompilerEndIf
  ProcedureReturn #False
EndProcedure
Maybe this is wrong:

Code: Select all

*obj\flags = *obj\flags &~ (1 << 11) 
But it should work as expected and it does here for the gadgets I've tested.
My favorite numbers: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
Post Reply