A couple of years ago or so, I posted this question.
Now I am including good source-code.
How do I make it (cross-platform) so that the mouse-wheel over the listicongadget only affects the vertical bar?
I am using a virtual listicongaget because it will store 10 000s of words.
Thanks!
Code: Select all
Declare update_vertical_scroll_bar_dictionary()
Enumeration
#WINDOW_MAIN
#PANEL_BOX_DICTIONARY
#PANEL_BOX_DICTIONARY_VERTICAL_BAR
EndEnumeration
Global number_of_words=100
Global Dim words$(number_of_words-1)
Global number_of_lines=13
For f=0 To number_of_words-1
words$(f)="Word #"+Str(f)
Next f
; Open a Window
If OpenWindow(#WINDOW_MAIN,0,0,1024,600,"Proofing Tool GUI",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)=#False : MessageRequester("Error", "Can't open a window.", 0) : EndIf
; Create the objects in the "Dictionary" tab
ListIconGadget(#PANEL_BOX_DICTIONARY,4,20-5,15+10+40+40+30+15+600-20+10+5+4+4+4-300-10-5-5-2,300-30+5+40,"#",30+40+10+5,#PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_CheckBoxes)
AddGadgetColumn(#PANEL_BOX_DICTIONARY,1,"Words",100+10+20+20+10)
AddGadgetColumn(#PANEL_BOX_DICTIONARY,2,"Tags",150+5+15+300)
ScrollBarGadget(#PANEL_BOX_DICTIONARY_VERTICAL_BAR,GadgetX(#PANEL_BOX_DICTIONARY)+GadgetWidth(#PANEL_BOX_DICTIONARY),20-5,25-5-2,300-30+5+40,0,0,number_of_lines,#PB_ScrollBar_Vertical)
; New code to handle the vertical scroll bar
SetGadgetAttribute(#PANEL_BOX_DICTIONARY_VERTICAL_BAR,#PB_ScrollBar_Maximum,number_of_words-1)
SetGadgetState(#PANEL_BOX_DICTIONARY_VERTICAL_BAR,0)
update_vertical_scroll_bar_dictionary()
BindGadgetEvent(#PANEL_BOX_DICTIONARY_VERTICAL_BAR, @update_vertical_scroll_bar_dictionary()) ; Dictionary
quit=#False
Repeat
event=WaitWindowEvent()
Select event
; User has pressed the close window gadget
Case #PB_Event_CloseWindow
quit=#True
EndSelect
Until quit=#True
End
Procedure update_vertical_scroll_bar_dictionary()
ClearGadgetItems(#PANEL_BOX_DICTIONARY)
If number_of_words=0
SetGadgetAttribute(#PANEL_BOX_DICTIONARY_VERTICAL_BAR,#PB_ScrollBar_Minimum,0)
SetGadgetAttribute(#PANEL_BOX_DICTIONARY_VERTICAL_BAR,#PB_ScrollBar_Maximum,0)
ProcedureReturn
EndIf
beginloop = GetGadgetState(#PANEL_BOX_DICTIONARY_VERTICAL_BAR)
; endloop = beginloop + 10
endloop=beginloop+number_of_lines-1
If endloop>ArraySize(words$())
endloop=ArraySize(words$())
EndIf
For f=beginloop To endloop
AddGadgetItem(#PANEL_BOX_DICTIONARY,-1,Str(f+1)+Chr(10)+words$(f))
SetGadgetItemColor(#PANEL_BOX_DICTIONARY,#PB_All,#PB_Gadget_FrontColor,$999999,0)
; If words_selected(f)=#True : SetGadgetItemState(#PANEL_BOX_DICTIONARY,f-beginloop,#PB_ListIcon_Checked) : EndIf
Next f
t=beginloop
t1=selected_dictionary_word-t
; If t1>=0 And t1<=10 : SetGadgetState(#PANEL_BOX_DICTIONARY,t1) : EndIf
If t1>=0 And t1<=number_of_lines-1 : SetGadgetState(#PANEL_BOX_DICTIONARY,t1) : EndIf
EndProcedure