| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| paul44 Expert Cheater
 
 ![]() Reputation: 2 
 Joined: 20 Jul 2017
 Posts: 206
 
 
 | 
			
				|  Posted: Sun May 18, 2025 10:47 am    Post subject: Checklistbox: OnItemClick fn does not get saved/accepted |   |  
				| 
 |  
				| image: see here [ https://ibb.co/album/NdwCkt ] 
 I can't seem to assign a function to 'OnItemClick': as soon as i leave the field, it gets removed.
 Note: i currently solve it by parkouring the complete list, and find the 'Selected' in question
 
 ps: tried all CE vs up to 7.5
 ps2: i assume that this particular event 'kicks in' the moment one clicks on any list_entry (which gets then selected in the process). Ie clicking on any other location within the listbox (incl checkboxes) has no effect (iow the fn will then not be called) ?!
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1528
 
 
 | 
			
				|  Posted: Sun May 18, 2025 5:37 pm    Post subject: |   |  
				| 
 |  
				| Here's an idea; 
 
  	  | Code: |  	  | -- Destroy existing form if it exists if myForm then myForm.Destroy() myForm=nil end
 
 -- Create a new form
 myForm = createForm()
 myForm.Caption = "Select Line: ..."
 myForm.Width = 300
 myForm.Height = 400
 
 -- Create a CheckListBox inside the form
 checkListBox = createCheckListBox(myForm)
 checkListBox.Width = 250
 checkListBox.Height = 200
 checkListBox.Left = 25
 checkListBox.Top = 50
 
 -- Add items to CheckListBox
 for i = 0, 3 do
 checkListBox.Items.add("Item " .. i)
 end
 
 ----------------------------------------
 
 -- Functions to handle selection changes
 function OnChange_d0(stt)
 if stt==1 then print(stt, "Hack ON!") else print(stt, "Hack OFF!") end
 end
 
 function OnChange_d1(stt)
 if stt==1 then print(stt, "Hack ON!") else print(stt, "Hack OFF!") end
 end
 
 function OnChange_d2(stt)
 if stt==1 then print(stt, "Hack ON!") else print(stt, "Hack OFF!") end
 end
 
 function OnChange_d3(stt)
 if stt==1 then print("Hack ON!") else print("Hack OFF!") end
 end
 
 local opts = 0 -- Option variable to manage click behavior
 
 -- Function to handle selection changes based on click type
 function onSelectionChange(sender)
 local index = sender.ItemIndex
 if index >= 0 then
 -- If checkbox is clicked, maintain its state
 if opts == 1 then
 sender.Checked[index] = sender.Checked[index]
 else
 -- If item text is clicked, toggle checkbox state
 sender.Checked[index] = not sender.Checked[index]
 end
 
 -- Call corresponding OnChange_d function
 local rn = _G["OnChange_d" .. index]
 local isState = sender.Checked[index] and 1 or 0 or nil
 rn(tonumber(isState))
 end
 opts = 0 -- Reset option variable
 end
 
 -- Triggered only when clicking on the checkbox
 checkListBox.OnClickCheck = function(s) opts=1 onSelectionChange(s) end
 
 -- Triggered only when clicking on the item text, does not affect checkbox
 checkListBox.OnClick = function(s) if opts~=1 then onSelectionChange(s) end end
 | 
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| paul44 Expert Cheater
 
 ![]() Reputation: 2 
 Joined: 20 Jul 2017
 Posts: 206
 
 
 | 
			
				|  Posted: Wed May 21, 2025 11:48 am    Post subject: |   |  
				| 
 |  
				| @AylinCE: thx for that code; i will try '.OnClick' probably this weekend; and report back... (problem w/ checkListBox, is no/minimal info; let alone about them event_functions)
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1528
 
 
 | 
			
				|  Posted: Thu May 22, 2025 11:17 am    Post subject: |   |  
				| 
 |  
				| I think it depends on the frequency of use; It is a control left to the Supply - Demand option. 
 On the other hand, the "OnClick" event alone would be an insufficient solution.
 OnClick only makes selections in the row and works independently of the box marking. (This would be like a normal "ListBox".)
 "OnClickCheck", on the other hand, only follows the box marking or unmarking.
 If both events are used, "OnClick" will return the valid result.
 The code above uses both events without any problems.
 
 
 You can add a row or something else to "rn(tonumber(isState))"  and send it to the function.
 
 
 Remember; In cases where a selection does not affect the other selections (If multiple selections can be made), it can be used in "ScrollBar" and "CheckBox" in it.
 
 However, depending on the necessity, the decision is yours.
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| paul44 Expert Cheater
 
 ![]() Reputation: 2 
 Joined: 20 Jul 2017
 Posts: 206
 
 
 | 
			
				|  Posted: Sun May 25, 2025 8:02 am    Post subject: Same result as done now... |   |  
				| 
 |  
				| image: [ https://ibb.co/Pz54DQwx ] 
 tried OnClick and OnClickItem (plus some other stuff), but the endresult is: Lstbox will always "respond" whether clicking on an item or just on some empty space...
 => bottomline: I'll live with the way it works now; since it was more of a finetuning AND see whether 'OnItemClick' would either work and/or make a difference...
 
 ps1: both OnClick & OnItemClick behave in the same way (when executed, it will print 'ItemIndex' of selected item (or -1)
 ps2: the "here" responds on the 'OnSelectionChange' (which is what i am using now. In all cases here, just clicking inside the listbox will execute...
 ps3: based on some 'stackoverflow' articles, i was expecting 'OnItemClick' to pass on both listbox- & item-object. I might have done something wrong here, but no cigar with the item_part...
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| Dark Byte Site Admin
 
  Reputation: 470 
 Joined: 09 May 2003
 Posts: 25807
 Location: The netherlands
 
 | 
			
				|  Posted: Sun May 25, 2025 11:56 am    Post subject: |   |  
				| 
 |  
				| selectionchange is better, as I figure using the keyboard to navigate through the list won't call OnItemClick 
 but yes, the OnItemClick seems to be a method not currently implemented
 _________________
 
 Do not ask me about online cheats. I don't know any and wont help finding them.
 Like my help? Join me on Patreon so i can keep helping
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		| AylinCE Grandmaster Cheater Supreme
 
  Reputation: 37 
 Joined: 16 Feb 2017
 Posts: 1528
 
 
 | 
			
				|  Posted: Sun May 25, 2025 2:44 pm    Post subject: |   |  
				| 
 |  
				| Possibly "OnSelectionChange" will work like the Address List. 
 The selected row will not interfere with the checkbox.
 
 If you want the row to be clicked to change the checkbox, check the code I gave first.
 
 Also "OnItemClick" and "OnClick" may have the same results. (Of course "OnClick" will indicate to click the last selected row if an empty area in the list is clicked.)
 
 
  	  | Code: |  	  | --f.PluginCheckListB.OnItemClick=function(sender) f.PluginCheckListB.OnClick=function(sender)
 showPluginInfo1(sender) --print = selection index and captions ..
 end
 
 function showPluginInfo1(sender)
 local index = sender.ItemIndex
 print(index)
 print(sender.Items[index]) -- captions
 end
 | 
 _________________
 
 |  | 
	
		| Back to top |  | 
	
		|  | 
	
		|  |