Sample Code
PB5.30 ListIcon always show selection
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
PB5.30 ListIcon always show selection
If a ListIconGadget has the #PB_ListIcon_AlwaysShowSelection flag and an out-of-view row is selected via SetGadgetItemState(#MyList, Row, #PB_ListIcon_Selected), shouldn't the ListIcon auto-scroll so that the row is in view?
Sample Code
Sample Code
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: PB5.30 ListIcon always show selection
Always show in this context, means it's always highlighted, that's all.
So if you click another gadget and lose the ListIcon's focus, you can
still see which item was selected in the ListIcon. With this flag off,
you don't see which item was selected anymore.
So if you click another gadget and lose the ListIcon's focus, you can
still see which item was selected in the ListIcon. With this flag off,
you don't see which item was selected anymore.
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.
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: PB5.30 ListIcon always show selection
...ah - I've been spoilt by Gonzal's lib 
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: PB5.30 ListIcon always show selection
Here's what I've been doing forever:
Code: Select all
Procedure GoToListItem(gad,i)
SetGadgetState(gad,-1) ; De-select any selected items.
SetGadgetState(gad,i-1) ; Now select the wanted item.
SendMessage_(GadgetID(gad),#LVM_ENSUREVISIBLE,i-1,0) ; And scroll to it.
EndProcedure
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.
- Andre
- PureBasic Team

- Posts: 2148
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: PB5.30 ListIcon always show selection
Maybe I've missed the related post (but couldn't find it via searchfunction) - is such a function "always show selected item" (= scroll to a programmatically selected item) also possible for OS X?
Re: PB5.30 ListIcon always show selection
You may take a look into this example for MacOS which demonstrates how to programmatically move a row or column into a visible area.Andre wrote:Maybe I've missed the related post (but couldn't find it via searchfunction) - is such a function "always show selected item" (= scroll to a programmatically selected item) also possible for OS X?
- Andre
- PureBasic Team

- Posts: 2148
- Joined: Fri Apr 25, 2003 6:14 pm
- Location: Germany (Saxony, Deutscheinsiedel)
- Contact:
Re: PB5.30 ListIcon always show selection
Thanks, shardik!Shardik wrote:You may take a look into this example for MacOS which demonstrates how to programmatically move a row or column into a visible area.Andre wrote:Maybe I've missed the related post (but couldn't find it via searchfunction) - is such a function "always show selected item" (= scroll to a programmatically selected item) also possible for OS X?
Using this tipp and the example of PB above I came up with this example.
Works fine on Windows, not tested yet on OS X...
Code: Select all
; http://www.purebasic.fr/english/viewtopic.php?f=13&t=60533
; combined PB help example with tipps from PB and Shardik by Andre
Procedure SelectnShowListItem(gad, item)
;SetGadgetState(gad, -1) ; De-select any selected items.
SetGadgetState(gad, item-1) ; Now select the wanted item.
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
SendMessage_(GadgetID(gad), #LVM_ENSUREVISIBLE, item-1, 0) ; And scroll to it.
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
CocoaMessage(0, GadgetID(gad), "scrollRowToVisible:", item-1)
CompilerElse
Debug "OS not supported (yet)!"
CompilerEndIf
EndProcedure
If OpenWindow(0, 100, 100, 300, 200, "ListIcon - Select and show a specific item", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListIconGadget(0, 5, 5, 290, 190, "Name", 100, #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
AddGadgetColumn(0, 1, "Address", 250)
For a = 1 To 20
AddGadgetItem(0, -1, "Mister " + Str(a) + Chr(10) + "Address " + Str(a))
Next
; Now select and show the 14th item:
SelectnShowListItem(0, 14)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
-
loulou2522
- Enthusiast

- Posts: 553
- Joined: Tue Oct 14, 2014 12:09 pm
Re: PB5.30 ListIcon always show selection
Is there someone similar with comboboxgadget which doen't highlited the first tiem when you enter a combobox ?
Thanks
Thanks
