Page 1 of 1
PB5.30 ListIcon always show selection
Posted: Mon Sep 15, 2014 12:44 pm
by IdeasVacuum
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
Re: PB5.30 ListIcon always show selection
Posted: Mon Sep 15, 2014 1:14 pm
by PB
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.
Re: PB5.30 ListIcon always show selection
Posted: Mon Sep 15, 2014 2:09 pm
by IdeasVacuum
...ah - I've been spoilt by Gonzal's lib

Re: PB5.30 ListIcon always show selection
Posted: Mon Sep 15, 2014 2:28 pm
by PB
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
Re: PB5.30 ListIcon always show selection
Posted: Tue Oct 11, 2016 11:08 pm
by Andre
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
Posted: Wed Oct 12, 2016 6:56 pm
by Shardik
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?
You may take a look into
this example for MacOS which demonstrates how to programmatically move a row or column into a visible area.
Re: PB5.30 ListIcon always show selection
Posted: Wed Oct 12, 2016 9:52 pm
by Andre
Shardik wrote: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?
You may take a look into
this example for MacOS which demonstrates how to programmatically move a row or column into a visible area.
Thanks, shardik!
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
Re: PB5.30 ListIcon always show selection
Posted: Thu Oct 13, 2016 8:52 am
by loulou2522
Is there someone similar with comboboxgadget which doen't highlited the first tiem when you enter a combobox ?
Thanks