PB5.30 ListIcon always show selection

Just starting out? Need help? Post your questions and find answers here.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

PB5.30 ListIcon always show selection

Post 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
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PB5.30 ListIcon always show selection

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PB5.30 ListIcon always show selection

Post by IdeasVacuum »

...ah - I've been spoilt by Gonzal's lib :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: PB5.30 ListIcon always show selection

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: PB5.30 ListIcon always show selection

Post 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?
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: PB5.30 ListIcon always show selection

Post 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.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: PB5.30 ListIcon always show selection

Post 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! :D

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... 8)

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
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
loulou2522
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Oct 14, 2014 12:09 pm

Re: PB5.30 ListIcon always show selection

Post by loulou2522 »

Is there someone similar with comboboxgadget which doen't highlited the first tiem when you enter a combobox ?
Thanks
Post Reply