It is currently Sat Nov 25, 2017 2:59 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 12:04 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5688
Location: Wales, UK
When you select a ListIcon row (mouse click) it is highlighted by default with the system highlight colour #COLOR_HIGHLIGHT.
However, when a row is selected programmatically, the highlight colour is a faint, dull grey instead. I think it should use #COLOR_HIGHLIGHT. Yes, I can apply the colour myself and keep track of row selections (or just unhighlight the whole list when a different row is selected), but that is a pita if a few cells have their own individual colour.

Is there a really simple way to get PB to use #COLOR_HIGHLIGHT when SetGadgetItemState() is applied?

Code:
Enumeration
#Win
#Panel
#Btn
#List
EndEnumeration

Global iRow.i, iCol.i, iExit.i = #False, iRow05.i = 5
Global sRow.s

Procedure PfSetListRowColours(iList.i, iRowColourEven.i, iRowColourOdd.i)
;#-----------------------------------------------------------------------
Protected       iRow.i
Protected  iRowIsOdd.i = #False
Protected iTotalRows.i = CountGadgetItems(iList)

              For iRow = 0 To (iTotalRows - 1)

                           If(iRowIsOdd = #True)

                                   SetGadgetItemColor(iList, iRow, #PB_Gadget_BackColor, iRowColourOdd, #PB_All)
                                   iRowIsOdd = #False
                           Else
                                   SetGadgetItemColor(iList, iRow, #PB_Gadget_BackColor, iRowColourEven, #PB_All)
                                   iRowIsOdd = #True
                           EndIf
              Next iRow
EndProcedure

If OpenWindow(#Win, 0, 0, 530, 300, "ListIcon Highlight Row", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

          PanelGadget(#Panel, 5, 5, 520, 290)

                  AddGadgetItem(#Panel, 0, "Tab 00")

                              ButtonGadget(#Btn,  10, 10, 200,  30, "Select Row 05")
                            ListIconGadget(#List, 10, 50, 490, 205, "Col 00", 100, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect)

                           AddGadgetColumn(#List,  1, "Col 01", 100)
                           AddGadgetColumn(#List,  2, "Col 02", 100)
                           AddGadgetColumn(#List,  3, "Col 03", 100)
                           AddGadgetColumn(#List,  4, "Col 04", 100)

                  For iRow = 0 To 10

                         sRow = ""

                         For iCol = 0 To 4

                                sRow = sRow + "Row" + RSet(Str(iRow),2,"0") + " Col" + RSet(Str(iCol),2,"0") + #LF$
                         Next

                         AddGadgetItem(#List, -1, sRow)
                  Next

                  PfSetListRowColours(#List, RGB(210,255,255), RGB(175,215,255))

                  AddGadgetItem(#Panel, 1, "Tab 01")

       CloseGadgetList() ;#Panel

       Repeat
                 Select WaitWindowEvent(1)

                        Case #PB_Event_CloseWindow: iExit = #True

                        Case #PB_Event_Gadget

                              Select EventGadget()

                                     Case #Btn

                                            SetGadgetItemState(#List, iRow05, #PB_ListIcon_Selected)
                                                  SetActiveGadget(#List) ;<---- Solution!
                              EndSelect
                 EndSelect

       Until iExit = #True
EndIf
End

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Last edited by IdeasVacuum on Sun Jul 16, 2017 1:37 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 12:35 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2848
Hi IdeasVacuum :P
I am afraid when you know the answer you will kill yourself :mrgreen:

http://www.purebasic.fr/english/viewtopic.php?f=5&t=68655

Code:
                                     Case #Btn

                                            SetGadgetItemState(#List, iRow05, #PB_ListIcon_Selected)
                                            SetActiveGadget(#List)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 12:52 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5688
Location: Wales, UK
:oops: I just don't drink enough coffee Rashad!
Mind you, it is technically a work-around.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved] ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 12:58 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2848
:mrgreen:
Not a workaround but maybe Fred should add SetFocus_() to the native command

BTW:
http://www.purebasic.fr/english/viewtopic.php?f=3&t=68774
No such command for ListIcon()
So you are asking for a new one

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved] ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 1:06 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5688
Location: Wales, UK
ah, GetGadgetText() is officially available for ListIcon (see help), but as-is it is pointless.
Yes yes yes, SetFocus_() should be incorporated :)

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 1:53 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5688
Location: Wales, UK
eek! No no no - neither SetActiveGadget() nor SetFocus_() are the real answer. What PB currently does, which is to change the background colour of the item most recently picked (#PB_ListIcon_AlwaysShowSelection), is correct.

For example, one of my apps has three ListIcons (single column), one each for Day, Month and Year selection, a la Android and the Web. All three ListIcons have a row pre-selected programmatically and all should be highlighted - and indeed they are, but not with #COLOR_HIGHLIGHT. SetActiveGadget()/SetFocus_() can only yield the desired result for one of them.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: [Solved] ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 2:01 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1027
RASHAD wrote:
maybe Fred should add SetFocus_() to the native command

Why? What if I want to change the selected item while keeping the gadget focus elsewhere? Example: my user clicks a button to highlight a matching item in the listicon, but the button shouldn't lose the focus after doing it, because the user may want to repeatedly click the button (or press it with Space) to highlight the next match -- like pressing the "Find Next" button with Space in Notepad to find the next occurrence of something in the text. Flipping the focus back and forth would be a pain in the ass. The focus should never change unless the user specifically initiated it.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 2:54 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2848
@Dude
SetFocus_() changed all the times with mouse click or changing the focused gadget, right?
SetFocus_() do not act for a single item but the all control SetFocus(hwnd)

Adding SetFocus_() will be only for SetGadgetItemState()(Manually select an item)

@IdeasVacuum
Your request is not available even with Windows API
But only with code
Code:
LoadFont(0,"Arial",12)
If OpenWindow(0, 0, 0, 640, 500, "Keep Selction", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0,  10,  10, 310, 200, "Column 0", 100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
  SetGadgetFont(0,FontID(0))
  AddGadgetColumn(0, 1, "Column 1" , 150)
  AddGadgetColumn(0, 2, "Column 2" , 150)
  For x = 0 To 100
    AddGadgetItem(0, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x)+Chr(10)+"Item "+Str(x))
  Next
 
  ListIconGadget(1,  320,  10, 310, 200, "Column 0", 100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
  SetGadgetFont(1,FontID(0))
  AddGadgetColumn(1, 1, "Column 1" , 150)
  AddGadgetColumn(1, 2, "Column 2" , 150)
  For x = 0 To 100
    AddGadgetItem(1, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x)+Chr(10)+"Item "+Str(x))
  Next
 
  ListIconGadget(2,  10,  220, 310, 200, "Column 0", 100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
  SetGadgetFont(2,FontID(0))
  AddGadgetColumn(2, 1, "Column 1" , 150)
  AddGadgetColumn(2, 2, "Column 2" , 150)
  For x = 0 To 100
    AddGadgetItem(2, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x)+Chr(10)+"Item "+Str(x))
  Next
 
  ListIconGadget(3,  320,  220, 310, 200, "Column 0", 100,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
  SetGadgetFont(3,FontID(0))
  AddGadgetColumn(3, 1, "Column 1" , 150)
  AddGadgetColumn(3, 2, "Column 2" , 150)
  For x = 0 To 100
    AddGadgetItem(3, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x)+Chr(10)+"Item "+Str(x))
  Next
 
  Dim olditem(3)
  ButtonGadget(4,10,470,100,20,"Select LI 0 Row 5")

EndIf
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0 To 3
            titem = GetGadgetState(EventGadget())
            SetGadgetItemColor(EventGadget(),olditem(EventGadget()), #PB_Gadget_BackColor,$FFFFFF)
            SetGadgetItemColor(EventGadget(),olditem(EventGadget()), #PB_Gadget_FrontColor,$0)             
            SetGadgetItemColor(EventGadget(),titem, #PB_Gadget_BackColor,GetSysColor_(#COLOR_HIGHLIGHT))
            SetGadgetItemColor(EventGadget(),titem, #PB_Gadget_FrontColor,$FFFFFF)
            olditem(EventGadget()) = titem
            If litem > 0
              SetActiveGadget(EventGadget())
            EndIf
           
        Case 4
            titem = 5
            SetGadgetItemColor(0,olditem(0), #PB_Gadget_BackColor,$FFFFFF)
            SetGadgetItemColor(0,olditem(0), #PB_Gadget_FrontColor,$0)             
            SetGadgetItemColor(0,titem, #PB_Gadget_BackColor,GetSysColor_(#COLOR_HIGHLIGHT))
            SetGadgetItemColor(0,titem, #PB_Gadget_FrontColor,$FFFFFF)
            olditem(0) = titem
           
      EndSelect
  EndSelect
Until Quit = 1

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 8:05 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1027
SetFocus_() is the same as SetActiveGadget(), so I wouldn't want the active gadget to be changed just because I manually set a listicon item.


Top
 Profile  
Reply with quote  
 Post subject: Re: ListIcon Selected Row Highlight
PostPosted: Sun Jul 16, 2017 10:01 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5688
Location: Wales, UK
Yeah, agreed Dude. Currently PB 'highlights' a programmatically picked item (#PB_ListIcon_AlwaysShowSelection) with a dull grey colour that is at best difficult to see. That is what I believe should be changed - just common sense.
http://www.purebasic.fr/english/viewtopic.php?f=13&t=68737

Hi Rashad, beat you to it and incorporated that method for my Day/Month/Year ListIcon trio, but there are two points about that. (1) Shouldn't really have to do it, the only reason it is necessary is the poor quality of the current arrangement.
(2) It gets a bit complicated when individual cells of a large ListIcon temporarily have their own background colour, defined at runtime by the User.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye