[Seen]Checkbox+Option gadgets dont mention any EventTypes

Found an issue in the documentation ? Please report it here !

Moderator: Documentation Editors

User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

[Seen]Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

Checkbox and Option gadgets dont mention which if any EventTypes are supported
(the word 'Event' doesnt even exist apart from WaitWindowEvent in the example)
User avatar
Demivec
Addict
Addict
Posts: 4267
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Demivec »

Keya wrote:Checkbox and Option gadgets dont mention which if any EventTypes are supported
(the word 'Event' doesnt even exist apart from WaitWindowEvent in the example)
They don't support any PureBasic events, so the listing in the manual appears correct.

I think this also means any OS associated events are handled entirely by the OS.

If a coder wanted to respond to OS events she might use a callback or BindGadgetEvents().
Last edited by Demivec on Mon Sep 14, 2015 3:09 pm, edited 1 time in total.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

Well, the listing in the manual would be "correct" if it actually said no events were supported, rather than not saying anything about it. :)

And to some extent an event is supported - if you specify an event for the Option or Checkbox gadget it does trigger an event, but with id 0. Im currently using that to detect state change.
But that isn't mentioned in the helpfile either.
Little John
Addict
Addict
Posts: 4786
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Little John »

Keya wrote:if you specify an event for the Option or Checkbox gadget it does trigger an event, but with id 0.
But that isn't mentioned in the helpfile either.
I think you shouldn't use that event in a normal program. That is probably the reason why it is not mentioned. ;-)
For CheckBoxGadgets and OptionGadgets, GetGadgetState() is supposed to provide the desired information.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

Little John wrote:I think you shouldn't use that event in a normal program. That is probably the reason why it is not mentioned.
Probably a good idea to mention it then!?!?!!!

And yes i know i can use GetGadgetState() - that's how i'm reading the state it's changed to ...

But I need to react when the state changes, so I need an Event of some sort, which ive set in the Visual Designer in its Event field

and that Event does trigger when i click the Option or Checkbox, but yes the Event = 0! (which isnt for example #PB_Event_LeftClick), so even though it works im not sure if im going about it the right way because of no helpfile information about it
Little John
Addict
Addict
Posts: 4786
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Little John »

Keya wrote:And yes i know i can use GetGadgetState() - that's how i'm reading the state it's changed to ...
That's what I'm doing, too. And I never needed anything else in this context.
CheckBoxGadgets and OptionGadgets do not work like ButtonGadgets.
User avatar
Demivec
Addict
Addict
Posts: 4267
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Demivec »

Keya wrote:But I need to react when the state changes, so I need an Event of some sort, which ive set in the Visual Designer in its Event field

and that Event does trigger when i click the Option or Checkbox, but yes the Event = 0! (which isnt for example #PB_Event_LeftClick), so even though it works im not sure if im going about it the right way because of no helpfile information about it
Use BindGadgetEvent(). In this sample code, the third checkbox has its state checked if any event is detected for it. It doesn't matter what it actually is, but it most like is a click event. In any case, that is when the state is checked.

Code: Select all

Procedure control_3()
  If GetGadgetState(2) = #PB_Checkbox_Checked
    DisableGadget(3, #False)
    DisableGadget(4, #False)
  Else
    DisableGadget(3, #True)
    DisableGadget(4, #True)
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 270, 160, "CheckBoxGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CheckBoxGadget(0, 10,  10, 250, 20, "Check everything")
    CheckBoxGadget(1, 10,  40, 250, 20, "Repeat everything"): SetGadgetState(1, #PB_Checkbox_Checked)
    CheckBoxGadget(2, 10,  70, 250, 20, "Use sub-options:"): SetGadgetState(2, #PB_Checkbox_Unchecked)
    CheckBoxGadget(3, 40, 90, 210, 20, "Sub-option 1"): DisableGadget(3, #True)
    CheckBoxGadget(4, 40, 110, 210, 20, "Sub-option 2"): DisableGadget(4, #True)
    
    BindGadgetEvent(2, @control_3())
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Verified for Windows 8.1 x64 PB5.40b3.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

Little John wrote:That's what I'm doing, too. And I never needed anything else in this context.
CheckBoxGadgets and OptionGadgets do not work like ButtonGadgets.
Open your mind a bit :). There are many reasons why you might want/need to react in realtime to an Option or Checkbox changing state.

For a simple example context, imagine a dialog you use for settings/options. You have a label "Mode", and two Option gadgets "Simple" and "Advanced". Under "Advanced" are several more gadgets that are only applicable when "Advanced" is enabled. So when you click the "Advanced" option you want to react so you can Enable those extra gadget items, and likewise Disable them when you click "Simple".

Demi, thankyou kindly for your demo, but is there actually any difference in using Bind rather than just associating the Event like normal via the Visual Designer? (They both just generate the 0 event?)
Little John
Addict
Addict
Posts: 4786
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Little John »

Keya wrote:There are many reasons why you might want/need to react in realtime to an Option or Checkbox changing state.
I'm aware that you want that.
However, as far as I understood Fred, CheckBoxGadgets and OptionGadgets currently just don't support that officially.
So there seems to be no "bug" in the documentation, but it seems that you want to make a feature request.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

Im sorry, i will post missing documentation reports to Feature Requests from now on.
Little John
Addict
Addict
Posts: 4786
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Little John »

Keya wrote:Im sorry, i will post missing documentation reports to Feature Requests from now on.
There is no need to document "features" that are not officially supported.
And there is no need to be chilly, just because I wrote my opinion here.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

There is no need to document "features" that are not officially supported.
I personally think a simple "This gadget doesn't support any Events" IS needed, otherwise this thread wouldn't exist, nor would anybody be confused about whether or not events are supported - Demivec wasn't 100% sure either.

You say the gadget doesnt support events, yet I am able to use the Visual Designer to assign an Event to it which does trigger when I click on it to change the state, so it is supported to some extent, but surely just a bit of clarification is needed here.

I dont understand how no information is better or "correct" than some information. I didn't think it was too much to ask :(
And there is no need to be chilly, just because I wrote my opinion here.
? i was just apologizing because you seemed annoyed at me posting here :( sorry for any confusion and if ive annoyed you
Last edited by Keya on Sun Sep 13, 2015 11:36 pm, edited 1 time in total.
Little John
Addict
Addict
Posts: 4786
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Little John »

I am sorry for any misunderstanding, too.
I was/am not annoyed.
I just wanted to say: If you want PB to support realtime events for OptionGadgets and CheckboxGadgets, then you should make a feature request.
Otherwise you won't get it. :-)
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Keya »

it's important information though so I just didn't see it as a "Feature Request" like my wish for native BSTR support but more of a "Bug" because it's needed, not desired. my bad
User avatar
Demivec
Addict
Addict
Posts: 4267
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Checkbox+Option gadgets dont mention any EventTypes

Post by Demivec »

Keya wrote:Demi, thankyou kindly for your demo, but is there actually any difference in using Bind rather than just associating the Event like normal via the Visual Designer? (They both just generate the 0 event?)
You're welcome.

I'm not sure about the difference. I wouldn't use the mysterious 0 event. When BindGadgetEvent() is used it isn't being used to distinguish the event but instead it causes a review of the check box's status when any event occurs that involves the check box. My guess is these OS events and I have only been able to test this on windows.

I do see at least one example of using dependent gadgets in the Preferences of the PB IDE under 'Session History', where a check box determines if other options are available. I know that the PB IDE is written in PureBasic also. Perhaps freak will share the method he uses if it doesn't involve any API and if that method is reliable on each OS.


I'm 100% sure that PureBasic defines no events for the check box. The manual lists no events for it under its own section and it also does not list it under the documentation for EventType().

I agree that it would be good to list it as having no events. This would make the manual more consistent. Some of the gadgets without events says "they have no events". A FrameGadget() and a TextGadget() are two examples.

I agree with Little John that it would be a feature request as opposed to a bug report.


In any case lets get some more consistency in the manual. :wink:


I wish you well.
Post Reply