Cannot show "&" in checkbox gadget

Just starting out? Need help? Post your questions and find answers here.
Allen
User
User
Posts: 92
Joined: Wed Nov 10, 2021 2:05 am

Cannot show "&" in checkbox gadget

Post by Allen »

Hi, in below code;

MainWindow=OpenWindow(1, 100, 100, 400,100, "Test")
CheckBoxGadget(2,10,10,100,20,"No & Eng")
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow

Only "No Eng" is displayed in the check box, the '&' disappear. Please help to confirm and advise. I am running PB5.73 x64 in win 10 pro.

Thanks

Allen
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot show "&" in checkbox gadget

Post by mk-soft »

The "&" sign is for shortkey (alternate). Unfortunately, the CheckBoxGadget does not support this in order to maintain the focus.

Code: Select all

MainWindow=OpenWindow(1, 100, 100, 400,100, "Test")
CheckBoxGadget(2,10,10,100,20,"No && &Eng")
Repeat 
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow 
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Allen
User
User
Posts: 92
Joined: Wed Nov 10, 2021 2:05 am

Re: Cannot show "&" in checkbox gadget

Post by Allen »

mk-soft,

Thank you for your solution, although I do not understand the reason you give. Can you advise where (in the manual) I can find more information.

Thanks

Allen Wong
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Cannot show "&" in checkbox gadget

Post by mk-soft »

This is Windows specific. For example, to access menus via the keyboard.

For more information see MSDN

Link: https://docs.microsoft.com/en-us/window ... bout-menus
Part: Menu Access Keys

Example

Code: Select all

;-TOP

Enumeration Windows
  #Main
EndEnumeration

Enumeration Menu
  #MainMenu
EndEnumeration

Enumeration MenuItem
  #MainMenuOpen
EndEnumeration

Enumeration Gadgets
  
EndEnumeration

Enumeration Status
  #MainStatusBar
EndEnumeration

Procedure Main()
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 400, 200, "Window" , #MainStyle)
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("&File")
    MenuItem(#MainMenuOpen, "&Open" + #TAB$ + "ALT+F4")
    
    AddKeyboardShortcut(#Main, #PB_Shortcut_Alt | #PB_Shortcut_F4, #MainMenuOpen)
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
        Case #PB_Event_Menu
          Select EventMenu()
            Case #MainMenuOpen
              MessageRequester("Open", "Menu open selected!")
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Allen
User
User
Posts: 92
Joined: Wed Nov 10, 2021 2:05 am

Re: Cannot show "&" in checkbox gadget

Post by Allen »

Programming is one of my hobbies. Normally I only write short programs; such as renaming photos from the exif data. PB is too powerful and I only use a very small part of it. Only recently I started to learn to use window gadgets. Thank you for the link and example and wish to learn more from this forum.

Thanks

Allen
Post Reply