Page 6 of 33

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 2:31 pm
by zikitrake
Rinzwind wrote:Impressive job. What's yet missing is full keyboard navigation.
Yes! :D

I just coded this piece, but I don't know how to scroll the ListEx to display current position when the selected row goes beyond the bottom of the gadget.

Code: Select all

Procedure key_up(listExID.l, steps.l = 1)
  Debug "key up!" 
  Protected curPos.l  
  
  curPos = ListEx::GetState(listExID)
  If curPos > 0    
    curPos - steps
    If curPos < 0: curPos = 0: EndIf
    ListEx::SetState(listExID, curPos)
  EndIf  
EndProcedure

Procedure key_down(listExID.l, steps.l = 1)
  Debug "key down!"    
  Protected rowCount.l = 0
  Protected curPos.l
  
  rowCount = ListEx::CountItems(listExID)    
  curPos = ListEx::GetState(listExID)  
  If curPos < (rowCount - steps)
    curPos + steps
    If curPos > (rowCount - steps): curPos = (rowCount - steps): EndIf
    ListEx::SetState(listExID, curPos)    
  EndIf
EndProcedure  

#Window  = 0
Enumeration 1
  #List
  #MyEventKeyUP
  #MyEventKeyDOWN
EndEnumeration

If OpenWindow(#Window, 0, 0, 400, 300, "Window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
  
  ListEx::Gadget(#List, 10, 10, 380, 280, "header", 360, "", ListEx::#GridLines)
  For cont = 1 To 30
    ListEx::AddItem(#List, ListEx::#LastItem, "Randy Roads")
    ListEx::AddItem(#List, ListEx::#LastItem, "Ozzy Osbourne")
  Next
  
  AddKeyboardShortcut(#Window, #PB_Shortcut_Up, #MyEventKeyUP)
  AddKeyboardShortcut(#Window, #PB_Shortcut_Down, #MyEventKeyDOWN)
  
  SetActiveGadget(#List)
  ListEx::SetState(#List,0)
  
  Repeat
    Event = WindowEvent()      
    MenuID = EventMenu()
    GadgetID = EventGadget()
    Select Event
        
      Case #PB_Event_Menu
        Select EventMenu()
          Case #myEventKeyDOWN
            If GetActiveGadget() = #List
              key_down(#List)
            EndIf
          Case #MyEventKeyUP
            If GetActiveGadget() = #List
              key_up(#List)
            EndIf          
        EndSelect
        
      Case #PB_Event_CloseWindow
      Case #PB_Event_Gadget
    EndSelect      
  Until Event = #PB_Event_CloseWindow
EndIf
CompilerEndIf

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 3:58 pm
by Thorsten1867
Update:
  • SetState() moves now the row into the visible area

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 4:21 pm
by zikitrake
Thorsten1867 wrote:Update:
  • SetState() moves now the row into the visible area
Thank you :!:

With my previous example, It works fine with down-key, but not for up-key (selected row go out of visible area)
Image

:oops: Sorry for inconvenences

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 4:38 pm
by Thorsten1867
I made a small change. Try it again!

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 5:00 pm
by zikitrake
Thorsten1867 wrote:I made a small change. Try it again!
Really thanks you!

Now it do a strange move:
Down-key is OK, but
first time UP-KEY is pressed it display from first row then, if you press UP-KEY again, it display the focused row
Image

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 5:09 pm
by Thorsten1867
Update:
  • Key control (Up/Down, PageUp/PageDown, Home/End)
  • Bugfix

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 5:51 pm
by zikitrake
Thorsten1867 wrote:Update:
  • Key control (Up/Down, PageUp/PageDown, Home/End)
  • Bugfix
Nice! but I still have the same issue that I mentioned in the previous post. With 20 or 30 more rows, when you press key down everything goes well, but when you press key up makes the effect of the image I put in my previous post.

Really, thank you very much for all these changes!

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Tue Jun 11, 2019 6:50 pm
by Thorsten1867
Try it again

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Wed Jun 12, 2019 8:24 am
by zikitrake
Edited/Updated

I think I found the issue: In Procedure SetVisible_(Row.i) I changed this line

ListEx()\Row\Offset = ListEx()\Row\Offset - Row to

ListEx()\Row\Offset = Row

And now everything seems to be fine (but I don't know if this change negatively affects other parts of code).

-------- ORIGINAL POST -------
Thorsten1867 wrote:Try it again
The problem persists (PB 5.70, Windows10 x64) :(
I just added these lines to have more rows to try.

Code: Select all

For cont = 1 To 100
  ListEx::AddItem(#List, ListEx::#LastItem, "Jack"     + #LF$ + "Jones"    + #LF$ + #LF$ + #LF$ + "Push")
Next
Image

Thank you for your effort and help!

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Wed Jun 12, 2019 11:01 am
by Thorsten1867
Update: Bugfix

The problem was a small mistake in thinking and the formula was really very simple. :shock:

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Wed Jun 12, 2019 4:46 pm
by zikitrake
Nice, all ok with cursor and focused row :D

On the other hand, would it be possible, after sorting the list, to keep the focus of the current row?

Thank you very much and I'm sorry to be so boring! :oops:

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Wed Jun 12, 2019 6:26 pm
by Lord
Lord wrote:...
Another thing:
Is it true, that ListEx::EventState(#List) in the example
always returns "0" when changing the three state checkbox?
In the meantime: has this been fixed?

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Wed Jun 12, 2019 6:46 pm
by Thorsten1867
Update:
  • Restore focus after sorting

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Thu Jun 13, 2019 9:42 am
by zikitrake
Thorsten1867 wrote:Update:
  • Restore focus after sorting
:D Thank you!
I am really amazed at what you are able to do for some of the members of this forum!

Re: [Modules] Editable and sortable ListGadget (all OS / DPI

Posted: Mon Jun 17, 2019 8:52 am
by zikitrake
Hi Thorsten1867, can you check this issue

After making ListEx::ClearItems() or ListEx::RemoveItem()
the value of ListEx::CountItems(#List) does not vary
(If the list had 10 rows, it continues to show 10)

Code: Select all

  If OpenWindow(0, 0, 0, 500, 200, "Window", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)    
    ListEx::Gadget(1, 10, 10, 400, 70, "header1", 125, "", ListEx::#GridLines)    
    For c  = 1 To 10
      ListEx::AddItem(1, ListEx::#LastItem, "Randy Rhoads")
    Next
    
    Debug ListEx::CountItems(1)
    ListEx::ClearItems(1)
    Debug ListEx::CountItems(1)
    
    Repeat: Until WaitWindowEvent()  = #PB_Event_CloseWindow     
  EndIf
For now I added this line on these procedures (clearItems() and removeItem())

Code: Select all

ListEx()\Row\Number  = ListSize(ListEx()\Rows())
And it seem works fine :D

Thank you!