Problems with: #PB_EventType_LeftClick
Firstly: (This problem is the most important .)
This line of code:
If EventGadget() = Index_List And EventType() = #PB_EventType_LeftClick ; Check for left click on the ListView
Isn't working .
Secondarily:
Each time I click on sorted Index_List
I get two of these: Debug ";- +++ Case Index_List"
and if I click on Index_List several consecutive times it stops working all together .
Problem area:
Code: Select all
;- Case Index_List
Case Index_List
Debug ";- +++ Case Index_List"
If EventGadget() = Index_List And EventType() = #PB_EventType_LeftClick ; Check for left click on the ListView
Debug "; Get the selected item index"
; Get the selected item index
selectedItem = GetGadgetState(Index_List) ; Assuming Index_List is the ID of the ListView
Debug "selectedItem = " +Str(selectedItem)
If selectedItem <> -1
; Fetch the text of the selected item
itemText$ = GetGadgetItemText(Index_List, selectedItem)
SetGadgetText(Search_String , itemText$)
EndIf
EndIf
;
Code: Select all
; PilgrimsProgress.pb ADD CreateButton ; ADD Procedure RemoveDuplicates()
EnableExplicit
;- Globals
Global StringGadget , line$ , Search_String , RepeatCount = 0 , Input_Editor_ItemText$ ,
Descend_CheckBox , Ascend_CheckBox , Descend_State = #PB_Checkbox_Checked ,
Ascend_State = #PB_Checkbox_Unchecked , selectedItem , itemText$ , Index_List ,
Create_Button , NewList Sort_List.s() , LisstSize , Index_List_Count = 0 , Quit = 0
; The ERROR could be that
;- Declares
Declare InitWindow()
Declare RemoveDuplicates()
; Create the main window
Procedure InitWindow()
OpenWindow(0, 0, 0, 1372, 854, "PilgrimProgress 2.0", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Search_String = StringGadget(#PB_Any, 416, 20, 170, 30, "the")
GadgetToolTip(Search_String , "Enter a Search-for Word .")
;
Create_Button = ButtonGadget(#PB_Any , 1062 , 20 , 120 , 30 , " Create Index")
;- Checkbox
Descend_CheckBox = CheckBoxGadget(#PB_Any, 1194 , 20 , 82 , 30 , "Desc")
GadgetToolTip(Descend_CheckBox, "LeftClick to Sort Index into Descending order .")
SetGadgetState(Descend_CheckBox, #PB_Checkbox_Checked)
;
Ascend_CheckBox = CheckBoxGadget(#PB_Any, 1276 , 20 , 118 , 30 , "Ascend")
GadgetToolTip(Ascend_CheckBox, "LeftClick to Sort Index in ASscending order .")
SetGadgetState(Ascend_CheckBox, #PB_Checkbox_Unchecked)
Index_List = EditorGadget(#PB_Any , 1060 , 70 , 300 , 762)
GadgetToolTip(Index_List, "LeftClick to SEND WORD to Search_String .")
;Sort_List
AddElement(Sort_List()) : Sort_List() = "Pliable" + #CRLF$
AddElement(Sort_List()) : Sort_List() = "Mr. Worldly Wiseman" + #CRLF$
AddElement(Sort_List()) : Sort_List() = "Destruction" + #CRLF$
AddElement(Sort_List()) : Sort_List() = "Swamp" + #CRLF$
AddElement(Sort_List()) : Sort_List() = "Obstinate" + #CRLF$
EndProcedure ; InitWindow()
;
Procedure RemoveDuplicates() ; [Create Index]
Global NewList LinesList.s() , NewList WordsList.s() , EventID ,
WordsListCOUNT = 0 , Number_Times_Thru = 0 ,
aLine$ , POS = 0 , StartPOS= 0 , LastPOD = 0 ,
Input_Editor_Line_Count = 0 , Editor_Current_Line_Number = 1
; ============================================================
; Extract lines from Input_Editor and Populate NewList WordsList.s() line-by-line
; ============================================================
; If Number_Times_Thru > 0 : Goto ReSort_WordList : EndIf
;- SortList
ReSort_WordList:
ClearGadgetItems(Index_List)
; ============================================================
Descend_State = GetGadgetState(Descend_CheckBox) ; #PB_Checkbox_Checked
If Descend_State = #PB_Checkbox_Checked
SortList(Sort_List() , #PB_Sort_Descending | #PB_Sort_NoCase) ; listIndex()
EndIf
; ============================================================
Ascend_State = GetGadgetState(Ascend_CheckBox) ; #PB_Checkbox_Checked
If Ascend_State = #PB_Checkbox_Checked
SortList(Sort_List() , #PB_Sort_Ascending | #PB_Sort_NoCase)
EndIf
; ============================================================
LisstSize = ListSize(Sort_List() )
Index_List_Count = 0
ForEach Sort_List()
SetGadgetItemText(Index_List , Index_List_Count , Sort_List())
Index_List_Count = Index_List_Count + 1
Next
;=============================================================
EndProcedure ; RemoveDuplicates()
;
InitWindow()
;- Event_Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
; MessageRequester("Case #PB_Event_Gadget" , "Case #PB_Event_Gadget")
Select EventGadget()
Case Create_Button
RemoveDuplicates()
;- Case Checkbox
Case Descend_CheckBox
SetGadgetState(Ascend_CheckBox , #PB_Checkbox_Unchecked)
SetGadgetState(Descend_CheckBox , #PB_Checkbox_Checked)
Case Ascend_CheckBox
SetGadgetState(Descend_CheckBox , #PB_Checkbox_Unchecked)
SetGadgetState(Ascend_CheckBox , #PB_Checkbox_Checked)
;- Case Index_List
Case Index_List
Debug ";- +++ Case Index_List"
If EventGadget() = Index_List And EventType() = #PB_EventType_LeftClick ; Check for left click on the ListView
Debug "; Get the selected item index"
; Get the selected item index
selectedItem = GetGadgetState(Index_List) ; Assuming Index_List is the ID of the ListView
Debug "selectedItem = " +Str(selectedItem)
If selectedItem <> -1
; Fetch the text of the selected item
itemText$ = GetGadgetItemText(Index_List, selectedItem)
SetGadgetText(Search_String , itemText$)
EndIf
EndIf
;
EndSelect
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
If Quit = 1
End
EndIf
ForEver


