Page 1 of 1

Renew DisableGadget() »»» EnableGadget() and DisableGadget()

Posted: Sat Apr 14, 2007 9:28 pm
by AND51
Hello!

The topic already says it: What you think about replacing
> DisableGadget(#Gadget, X)
by
> EnableGadget(#Gadget)
> DisableGadget(#Gadget)
?

This would less to write and it makes more sense: If I want to enable a gadget, why should I use DisableGadget??


The state of a gadget can only be 1 or 0, so IMHO this would be a nice feature.

By the way: Checkboxes can have 3 sates: 0, 1 and a state which indicates that not all objects are meant (in this case the checkbox' backgorund is grayed and checked in windows).



Regardless of implementing this feature: Is it possible to add the 3rd state for the checkbox?
My suggesttion would be the following then:

Code: Select all

DisableGadget(#Gadget)         ; Disables a gadget
EnableGadget(#Gadget, [State]) ; Enables a Gadget, 'State' is optional, it's only needed with Checkboxes

Posted: Sat Apr 14, 2007 9:33 pm
by Trond
This would less to write and it makes more sense: If I want to enable a gadget, why should I use DisableGadget??
It's nice if you don't know until run-time how you want the gadget to be. For example, you can have this procedure called every time a gadget value is changed:

Code: Select all

Changed = CheckIfPreferencesHasChangedSinceLastApply()
DisableGadget(ApplyButton, 1-Changed)
With Enable/Disable you need to wrap the call into an If/Else.

Posted: Sat Apr 14, 2007 9:42 pm
by AND51
> With Enable/Disable you need to wrap the call into an If/Else.
Sorry, I didn't consider this reason.

Then, I refresh my suggestion: Both commands shoul dbe included, both may have an optional flag:

> DisableGadget(#Gadget, [State])
If 'State' is 1, gadget is disabled (like the current PB version does), 0 enables the gadget => usefule for the code Trond has shown (btw, this makes your old code running as usual - no update needed)

> EnableGadget(#Gadget, [State])
If 'State' is 1, the gadget is enabled, if 'State' is 2 (for example), this is only relevant for checkboxes and makes them turning into the "3rd state".


Please, tell me your opinion about this.

Posted: Sat Apr 14, 2007 9:53 pm
by yoxola
SetGadgetState(#Gadget, [State])
0 = disabled
1 = enabled
3/4 = checkbox/etc...

This come to my mind, altough you can wrap it easily with existing functions....

Posted: Sat Apr 14, 2007 9:59 pm
by AND51
This would be a nice idea, but you can't use this.

Remember, you can use SetGadgetState() also with ListViews and ListIcons. What do you do, if you want to select (not check!) the 1st, 2nd, 3rd or 4th item in those gadgets?

But through your post, I got an important idea: If The PB Team includes this feature, GETGadgetState() must be changed to what you wrote, yoxola!

> This come to my mind, altough you can wrap it easily with existing functions....
Although, I'm not a PB-beginner any more, I would appreciate these funtions natively.
1) There are always beginners who want to use this
2) Why should I write more code, when there could be this nice feature?

Posted: Sun Apr 15, 2007 5:16 pm
by yoxola
It's just a suggestion, if you are used in the C/C++, it's something common, actually I think your suggestion won't be taken soon on a minor release, if there's PB 5.0 it could happen.

Yeas, it's boring that you have to write something by your own, but you can save it as include file.

Posted: Sun Apr 15, 2007 6:12 pm
by AND51
Sorry, I'm not familiar with C/C++... Currently, I do use macros, but this is not satisfying somehow (IMHO).

Furthemore, the codes I've posted are just a suggestion, it may change when it's applied to PB.

Posted: Sun Apr 15, 2007 7:46 pm
by Leonhard
Using this:

Code: Select all

Macro __DisableGadget(Gadget, State)
  DisableGadget(Gadget, State)
EndMacro
Macro DisableGadget(Gadget, State = #True)
  __DisableGadget(Gadget, State)
EndMacro
Macro EnableGadget(Gadget)
  DisableGadget(Gadget, #False)
EndMacro

Posted: Sun Apr 15, 2007 9:04 pm
by AND51
Hi Leonhard!

I already use this macro; but it does not give you the ability to give a checkbox the "3rd state".

I would like to hear the opinion of the PB team :) regarding this thread.

Posted: Sun Apr 15, 2007 9:44 pm
by Fred
The 3rd checkbox is really a Windows only stuff (wierd one BTW). About the EnableGadget(), we have decided to limit the number of functions in PB to have compact commandset. It also allow to change the state programmatically without having to do an "If" which is a great plus.

Re: Renew DisableGadget() »»» EnableGadget() and DisableGadg

Posted: Sun Apr 15, 2007 9:48 pm
by PB
@AND51: This was already discussed a long time ago:
http://www.purebasic.fr/english/viewtopic.php?t=19832

Posted: Thu Apr 19, 2007 10:57 pm
by AND51
thx for your answers!