B4J Question Checkbox doesn not fire event?!

prokli

Active Member
Licensed User
Does a checkbox not fire an event, when I changed its value by mouse?


My code:

Sub Process_Globals
Private CopyChkBox As CheckBox
End Sub


Sub AppStart (Form1 As Form, Args() As String)

CopyChkBox.Initialize("CopyEv")

End Sub


Sub CopyEv_CheckedChange(Checked As Boolean)
Log(Checked)
End Sub


Whenever I programmatically write a "True" or "False" to the checkbox's value, the event is fired. But when I change the value by mouse it is not!
Thanks for any help!
 

Martincg

Member
Licensed User
You need
Sub CopyEv_CheckedChange(Checked As String)


Edit
Oops, this could be wrong, I've just noticed this is the B4J forum not B4A although I would have expected these things to be similar.
 
Last edited:

stevel05

Expert
Licensed User
Is the CopyChkBox added with the Scene Builder and loadlayout? If so, you shouldn't initialize it in your code. Add the eventname to the Node ID in the Scene Builder.
 

prokli

Active Member
Licensed User
Yes I created the Checkbox by the Scene Builder and added a name to the ID field.
But if I do not initialize the checkbox programmatically I receive an error while compiler runs.
But please read my first post: the event is fired when I write a TRUE or FALSE to the checkbox value.
It is not fired, when I click into the box with my mouse and that was my question!!!
 

stevel05

Expert
Licensed User
Then the problem you get when compiling is the one you need to solve, you should not initialize a view in code that is added with Scene Builder. What is the compilation error. Zip (From the file menu) and post your project if you can it will make it easier to help.
 

stevel05

Expert
Licensed User
OK well as I can't see the code I'll have to ask you. What ID have you assigned to the checkbox in SceneBuilder? It should be the same as the related Dim / Private statement, that is also your eventname.
 

prokli

Active Member
Licensed User
Please refer to the attached image.
I used exactly the same expression and let me say this again: the event ist fired when I write a value to the checkbox value by code.
It is not fired when I click on the ckeckbox
Builder.png
by mouse. This is what I am asking.
Thanks!
 

stevel05

Expert
Licensed User
Well your code seems to be inconsistent, you have ckbCopy as the ID for the checkbox in Scene Builder, then in Process_Globals you have Private CopyChkBox As CheckBox and the Sub is Sub CopyEv_CheckedChange(Checked As Boolean). All three names should be the same.
 
Top