ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Just starting out? Need help? Post your questions and find answers here.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Post by horst »

ListIcon checkbox status must not be changed by space bar in conjunction with ALT or Ctrl.

ALT+space is reserved for the system menu which may be used to close the window. Very annoying if checkbox status is unintentionally changed (especially when hidden under the menu).
Ctrl+space is reserved for deselecting an item.

Code: Select all

OpenWindow(0,200,200,200,300,"Test ListIcon Checkbox",#PB_Window_SystemMenu)
ListIconGadget(1,0,0,200,300,"ListIconGadget",170,#PB_ListIcon_CheckBoxes)
For i = 100 To 120 :  AddGadgetItem(1,-1,Str(i)) : Next 
SetActiveGadget(1)
SetGadgetState(1,10)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Horst.
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Post by Fred »

I agree but it seems like a Windows stuff here, as you can see with this full API example:

Code: Select all

colinfo.LV_COLUMN 
colinfo\mask = #LVCF_TEXT|#LVCF_WIDTH|#LVCF_FMT 
colinfo\fmt = #LVCFMT_LEFT 
colinfo\cx = 160

hwnd = OpenWindow(0,0,0,800,600, "API Listview",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
lv = CreateWindowEx_(#WS_EX_STATICEDGE , "SysListView32", "MyListView", #LVS_REPORT | #WS_CHILD | #WS_VISIBLE | #WS_HSCROLL | #WS_VSCROLL , 10,10,780,580,hwnd,0,0,0) 

SendMessage_(lv, #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_CHECKBOXES, #LVS_EX_CHECKBOXES)

For x = 0 To 5
  header$= "Column Header "+Str(x)
  colinfo\pszText = @header$
  SendMessage_(lv, #LVM_INSERTCOLUMN, x, @colinfo) 
Next

line.LV_ITEM 
line\Mask     = #LVIF_TEXT 
For i=0 To 120
  linetxt.s = "text entry "
  line\iitem = i
  line\pszText  = @linetxt
  SendMessage_(lv, #LVM_INSERTITEM, 0, @line)
  For c = 1 To 5
    col.LV_ITEM 
    coltext.s = "text entry " + Str(i) + " " +Str(c)
    col\Mask     = #LVIF_TEXT 
    col\iitem = i
    col\iSubItem = c
    col\pszText  = @coltext
    SendMessage_(lv, #LVM_SETITEM, 0, @col)
  Next
Next

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Post by Blue »

Verified.

Windows 11 behaves effectively as Fred says and as Horst wants to avoid.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Post by RASHAD »

Hi horst
While it's an Old thread :)
For time been next is so simple workaround beside it Maybe Cross - Platform

Code: Select all

OpenWindow(0,200,200,200,300,"Test ListIcon Checkbox",#PB_Window_SystemMenu)
ListIconGadget(1,0,0,200,300,"ListIconGadget",170,#PB_ListIcon_CheckBoxes)
For i = 100 To 120 :  AddGadgetItem(1,-1,Str(i)) : Next 
SetActiveGadget(1)
SetGadgetState(1,10)
AddKeyboardShortcut(0,#PB_Shortcut_Alt|#PB_Shortcut_Space,10)
AddKeyboardShortcut(0,#PB_Shortcut_Control|#PB_Shortcut_Space,20)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Egypt my love
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: ListIconGadget, Checkbox, ALT/Ctrl + Space Bar

Post by Blue »

That works very well, Rashad.
Brilliant workaround !
You may want to add a combination of your 2 shortcuts to make it a complete solution:

Code: Select all

AddKeyboardShortcut(0,#PB_Shortcut_Alt|#PB_Shortcut_Control|#PB_Shortcut_Space,10)
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Post Reply