PB4B4: Set...State instead of Disable...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

PB4B4: Set...State instead of Disable...

Post by USCode »

:idea: Suggestion:
For consistency and clarity, shouldn't the following "Disable..." commands be replaced by the "Set...State" commands instead?

DisableGadget --> SetGadgetState
DisableMenuItem --> SetMenuItemState
DisableToolBarButton --> SetToolBarButtonState
DisableWindow --> SetWindowState

For example,
To "Enable" a Gadget now, you must do this:

Code: Select all

DisableGadget(#Button_1, #False)
which I find counter-intuitive.

Instead this might be better to Enable the Gadget:

Code: Select all

SetGadgetState(#Button_1, #PB_State_Enabled)
or to Disable:

Code: Select all

SetGadgetState(#Button_1, #PB_State_Disabled)
The same would follow similarily for all the commands and GUI elements listed above.

#PB_State_Enabled and #PB_State_Disabled could possibly even be used for all the commands?

Perhaps even SetGadgetItemState could be used to enable/disable individual gadget items as well?

We would have four less commands to remember (any others?) and Set...State seems more intuitive and consistent for setting the enabled/disabled "states"?

[Edit]
-- See post below about maybe also replacing HideGadget and HideMenu using Set...State instead as well --
Last edited by USCode on Sat Feb 25, 2006 10:17 pm, edited 3 times in total.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

I support this idea...

Post by Michael Vogel »

...when I saw the commands the first time I also wondered why they are named "so negative" - so please change them (or add) to have a more positive life!
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Maybe Hide... could be replaced by Set...State as well???

Post by USCode »

:idea: I wonder if this could ALSO be applied to HideGadget and HideMenu?
I would consider the visibility of something to be a "state" as well, along with the aforementioned enabled/disabled. Others?

E.g.

Code: Select all

HideGadget(#Button_0, #False)
isn't real intuitive.

Code: Select all

SetGadgetState(#Button_0, #PB_State_Invisible)
might be better.

Constants:
#PB_State_Visible
#PB_State_Invisible

or maybe alternatively:
#PB_State_Show
#PB_State_Hide

As we're still in Beta, now's the time to consider these things I guess!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

what values for your constants want to use, that not conflict with the normal
SetGadgetState Values. The old way is better for me
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

Post by va!n »

i agree with USCode his command names

DisableGadget --> SetGadgetState
DisableMenuItem --> SetMenuItemState
DisableToolBarButton --> SetToolBarButtonState
DisableWindow --> SetWindowState
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

PB4?

Post by USCode »

Whatddya think PB team, yeah or nay, for these command changes for PB4?
(see details in above posts)

DisableGadget --> SetGadgetState
DisableMenuItem --> SetMenuItemState
DisableToolBarButton --> SetToolBarButtonState
DisableWindow --> SetWindowState

HideGadget --> SetGadgetState
HideMenu --> SetMenuItemState
(does this apply to both menus and menu items?)

Clearer the old way?
Technically not easily doable or inconsistent?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You really try to make you life harder here.. It won't be changed, i don't see what's wrong with current commands (except it's faster to write and easier to read).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

I also agree with USCode couse:

DisableGadget does not only disable a gadget. It also enables it. Logicaly there must be an EnableXXXX-Commands too.
Tranquil
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

From MSDN for the EnableWindow API: The EnableWindow function enables
or disables mouse and keyboard input to the specified window or control.


Therefore, I think it makes perfect sense to describe what the function is
doing. EnableWindow and DisableGadget make it perfectly clear. If this was
changed to SetGadgetState, then what state are we actually changing? The
enabled state? The visibility? Whether the gadget has normal or "flat" borders?
There's too many possibilities -- is Fred supposed to create a constant for each
type of state, and make the command apply the correct one? This would surely
lead to a performance hit and a bloated command.

Besides, SetGadgetState already exists and does totally different functions. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

Fred wrote:You really try to make you life harder here.. It won't be changed, i don't see what's wrong with current commands (except it's faster to write and easier to read).
Well I knew it would be one of those "love it or hate it" type of things so I just threw it out there as a suggestion. I had my preference but I can understand both sides of the argument and Fred's made his decision, so I can live with it. :wink:
Post Reply