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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

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

Post 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
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
yoxola
Enthusiast
Enthusiast
Posts: 386
Joined: Sat Feb 25, 2006 4:23 pm

Post 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....
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
yoxola
Enthusiast
Enthusiast
Posts: 386
Joined: Sat Feb 25, 2006 4:23 pm

Post 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.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Leonhard
User
User
Posts: 55
Joined: Fri Jun 16, 2006 7:43 am

Post 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
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

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

Post by PB »

@AND51: This was already discussed a long time ago:
http://www.purebasic.fr/english/viewtopic.php?t=19832
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

thx for your answers!
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply