Yes!Rinzwind wrote:Impressive job. What's yet missing is full keyboard navigation.
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