Page 2 of 2
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Sun Nov 10, 2024 7:02 pm
by mk-soft
Why should this be corrected? It's fine the way it is.
They are constants that Fred has defined, just as you can create constants for your purposes in your programme.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Mon Nov 11, 2024 8:10 am
by jacdelad
mestnyi wrote: Sun Nov 10, 2024 6:31 pm
mk-soft wrote: Sat Nov 09, 2024 11:54 pm
EventType() = #Null is ...
That's true, but Fred doesn't want to fix this situation in any way. moreover, I do not understand how the event value can be zero.
Since you firstly check the #PB_Event_... value, there's no problem when it's zero.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Mon Nov 11, 2024 8:26 pm
by mestnyi
mk-soft wrote: Sun Nov 10, 2024 7:02 pm
Why should this be corrected? It's fine the way it is.
They are constants that Fred has defined, just as you can create constants for your purposes in your programme.
yes, at least because it is illogical why this theme was created, and because it is more logical that there should be a change in the event rather than a click event. I have a counter question, why was the loop banned inside bindevent?
why is the value 0 incorrect, for example, such use is not possible
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Mon Nov 11, 2024 9:01 pm
by Demivec
mestnyi wrote: Mon Nov 11, 2024 8:26 pm
mk-soft wrote: Sun Nov 10, 2024 7:02 pm
Why should this be corrected? It's fine the way it is.
They are constants that Fred has defined, just as you can create constants for your purposes in your programme.
yes, at least because it is illogical why this theme was created, and because it is more logical that there should be a change in the event rather than a click event. I have a counter question, why was the loop banned inside bindevent?
why is the value 0 incorrect, for example, such use is not possible
The EventType() value of zero for a checkbook gadget is incorrect because the defined event types for a checkbox is the empty set not the set containing zero.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Mon Nov 11, 2024 9:48 pm
by AZJIO
mestnyi wrote: Mon Nov 11, 2024 8:26 pm
Faulty logic. If there is no event, then its type does not exist. If an event has arrived, then it must have a type. Defining an event by the absence of a type is absurd. If you assume that you would like to check for the absence of a type before checking 5 different types in order to speed up the code, then the disappointment is that even if there was a value that determines the absence of a type, it still would not help you, since the number is not a the absence of a type and it would still force you to make checks with all five types. Roughly speaking, if you want to ignore an event by type, then simply call EventGadget() first, and if there is no event, then there will be no type.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Wed Nov 13, 2024 7:28 pm
by mestnyi
AZJIO wrote: Mon Nov 11, 2024 9:48 pm
mestnyi wrote: Mon Nov 11, 2024 8:26 pm
Faulty logic. If there is no event, then its type does not exist. If an event has arrived, then it must have a type. Defining an event by the absence of a type is absurd. If you assume that you would like to check for the absence of a type before checking 5 different types in order to speed up the code, then the disappointment is that even if there was a value that determines the absence of a type, it still would not help you, since the number is not a the absence of a type and it would still force you to make checks with all five types. Roughly speaking, if you want to ignore an event by type, then simply call EventGadget() first, and if there is no event, then there will be no type.
This is exactly the same infallible logic.

Re: CheckBox doesn't support #PB_EventType_Change
Posted: Thu Nov 14, 2024 11:52 am
by BarryG
First post edited to better clarify what I'm requesting.

Re: CheckBox doesn't support #PB_EventType_Change
Posted: Mon Nov 25, 2024 6:23 am
by Psych
Checkboxes, as far as I am aware, just fire as a GadgetEvent, EventGadget() tells you the checkbox, and the event is ALWAYS a change of state (and even if by some weird situation it isn't, what harm would that do?)
So just check for that.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Wed Feb 05, 2025 7:09 pm
by Piero
Would this work?
Code: Select all
Enumeration CheckBoxes
#__CheckBox_index_start = 1000
#myCheckBox1
#myCheckBox2
#__CheckBox_index_end
EndEnumeration
If OpenWindow(0,0,0,270,170,"CheckBoxGadget",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CheckBox_index = #__CheckBox_index_end
CheckBoxGadget(CheckBox_index, 10,70,250,20,~"\"runtime CheckBox\"")
CheckBox_index+1
CheckBoxGadget(CheckBox_index, 10,100,250,20,~"\"runtime CheckBox\"")
CheckBox_index+1
CheckBoxGadget(#myCheckBox1, 10,10,250,20,"standard CheckBox")
CheckBoxGadget(#myCheckBox2, 10,40,250,20,"standard CheckBox")
StringGadget(0,10,130,250,20,"")
Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Gadget
if EventType() = #PB_EventType_Change or EventGadget() > #__CheckBox_index_start
Debug "Gadget changed: " + EventGadget()
EndIf
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Fri Feb 07, 2025 1:41 am
by ChrisR
I have no problem on my side with checkboxes without EventType(),
But on the other hand, the same question deserves to be asked for optionGadget. If an option is already enabled and we click on it, there is no status change but yet we receive an event that is useless.
Either we should have #PB_EventType_Change, or an event only if there is a real status change.
Code: Select all
Define GadgetChanged
If OpenWindow(0, 0, 0, 270, 100, "Changed", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CheckBoxGadget(0, 10, 10, 250, 20, "CheckBox standard")
StringGadget(1, 10, 40, 250, 20, "")
OptionGadget(2, 10, 70, 120, 20, "Option 1")
OptionGadget(3, 140, 70, 120, 20, "Option 2")
Repeat
ev=WaitWindowEvent()
If ev=#PB_Event_Gadget And IsGadget(EventGadget())
Select GadgetType(EventGadget())
Case #PB_GadgetType_ComboBox, #PB_GadgetType_Date, #PB_GadgetType_Editor, #PB_GadgetType_ExplorerList, #PB_GadgetType_ExplorerTree,
#PB_GadgetType_Image, #PB_GadgetType_ListIcon, #PB_GadgetType_Spin, #PB_GadgetType_String, #PB_GadgetType_Tree ;#PB_GadgetType_Panel
If EventType()=#PB_EventType_Change
GadgetChanged = #True
EndIf
Case #PB_GadgetType_CheckBox
GadgetChanged = #True
Case #PB_GadgetType_Option
;State = GetGadgetState(EventGadget())
; it can't be done like this, because we don't receive an event if we click on another option of the same group
;If State <> GetGadgetData(EventGadget())
; SetGadgetData(EventGadget(), State)
GadgetChanged = #True
;EndIf
EndSelect
If GadgetChanged
Debug "Either a CheckBox or StringGadget changed"
GadgetChanged=0 ;Reset for testing other changes in this example
EndIf
EndIf
Until ev= #PB_Event_CloseWindow
EndIf
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Fri Feb 07, 2025 2:19 am
by AZJIO
ChrisR wrote: Fri Feb 07, 2025 1:41 am
Code: Select all
If ev=#PB_Event_Gadget And IsGadget(EventGadget())
Select GadgetType(EventGadget())
Can the result of EventGadget() change when it is repeated? I’ll ask differently: is the call of WaitwindowEvent() filling a certain structure, after which the functions of the EventGadget() and EventType() functions and others simply receive data from this structure?
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Fri Feb 07, 2025 2:30 am
by ChrisR
I don't think EventGadget(), EventType(),... changes.
They are sent for each Event as in PostEvent(Event [, Window, Object [, Type [, Data]]])
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Fri Feb 07, 2025 3:09 am
by AZJIO
However, WaitwindowEvent () returns a new event each time. If it is logically reasoning, then other functions should not return the codes from other events, given that even the mouse movement can create a dozen events per second. So the function cachs the value associated with the captured event.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Fri Feb 07, 2025 3:46 am
by Demivec
AZJIO wrote: Fri Feb 07, 2025 3:09 am
However, WaitwindowEvent () returns a new event each time. If it is logically reasoning, then other functions should not return the codes from other events, given that even the mouse movement can create a dozen events per second. So the function cachs the value associated with the captured event.
New events are retrieved from the event queue only when WaitWindowEvent() or WindowEvent() is called. The event retrieved becomes the most recent event.
If an event is bound with a Bind function then the assigned handling procedure for the binding will be executed. After all triggered procedures associated with bindings for the most recent event execution then continues with the next statement after the function that retrieved the event (eitherWaitWindowEvent() or WindowEvent()).
All of the informational functions for events ( i.e. Event(); EventData(); EventGadget(); EventMenu(); EventTimer(); EventType(); EventWindow(); EventlParam(); EventwParam() ), return information for only the most recent event. As long as there isn't a new event retrieved from the event queue with eitherWaitWindowEvent() or WindowEvent().
The informational functions for events are available for use both inside and outside the event handling procedures that are assigned with a Bind function.
Re: CheckBox doesn't support #PB_EventType_Change
Posted: Sat Feb 08, 2025 9:42 pm
by Piero
So it would be useful to know if the OptionGadget
GROUP changed…
PS:
I had forgot IsGadget and GadgetType…
It's all clearer now, even how/where to find the right "events stuff" on Help…
Thanks!