Page 1 of 1 1
Topic Options
#90775 - 2003-01-03 03:36 PM KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Shawn - I found a bug...er...feature...

If you put lines in this order, ESCAPE doesn't work:

$ButtonOk.Cancel=1
$ButtonOk.Default=1

If you reverse them, it does work:
$ButtonOk.Default=1
$ButtonOk.Cancel=1

FYI. It was a little confusing to a friend.

Crazy Eddie
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90776 - 2003-01-03 04:54 PM Re: KixForms "Feature"
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
Shawn - To save you a little time you can use this little snippet to test (since I decided to see the behavior). It appears Default cancels Cancel [Wink] .
code:
BREAK ON
$FORM = CREATEOBJECT("KIXTART.FORM")
$FORM.SCALEHEIGHT = 50
$FORM.SCALEWIDTH = 100

$BUTTON = $FORM.COMMANDBUTTON("BUTTON")
$BUTTON.HEIGHT = 19
$BUTTON.WIDTH = 80
$BUTTON.LEFT = 10
$BUTTON.TOP = 15
$BUTTON.ONCLICK = "CLICK()"
$BUTTON.CANCEL = 1
$BUTTON.DEFAULT = 1
;$BUTTON.CANCEL = 1

$FORM.SHOW
WHILE $FORM.VISIBLE
$ = EXECUTE($FORM.DOEVENTS)
LOOP

FUNCTION CLICK()
$ = MESSAGEBOX("HELLO","HELLO")
ENDFUNCTION

-Ben
http://www.rgcweb.org/kix

Top
#90777 - 2003-01-03 05:55 PM Re: KixForms "Feature"
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
If you test the two properties a bit further you'd see that one can't have it active on one control at the same time .. the one that is the last overwrites the preceeding [Wink]

I have had a short discussion with Shawn about that, and he said something about this is 'expected' (It was really short [Wink] )

Shawn ?
Could we have a deeper explanation ?

J.
_________________________



Top
#90778 - 2003-01-03 05:59 PM Re: KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
I'm not sure why that might be. I'd love to hear from Shawn on the issue.

They (logically in use) don't need to be mutually exclusive.

Many display forms would want escape and enter to close the form. That's how I'm using it.

-Crazy Eddie
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90779 - 2003-01-03 06:22 PM Re: KixForms "Feature"
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
The current strategy being used to flag buttons as either default or cancel will not allow for a button to act as both ... but I agree with you, buttons that act as both would be usefull (like the close form thingy just mentioned).

Will have to do a little experimenting but based on some of the development work going on right now (building a new custom button) think there might be a way to do this - will give a go for next release.

-Shawn

Top
#90780 - 2003-01-03 06:25 PM Re: KixForms "Feature"
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
In my code if you have the Cancel property set last then the CommandButton is still the default and at the same time ESC will execute the button, too. However, if you set Default after Cancel, then the button executes when enter is hit, but does nothing when ESC is hit. So I'm not sure if they're supposed to be exclusive, but they only are in one circumstance.

-Ben
http://www.rgcweb.org/kix

Top
#90781 - 2003-01-03 06:30 PM Re: KixForms "Feature"
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
hmmm... im wondering if thats only because you have one button on the form ? lets give your script a shot ...
Top
#90782 - 2003-01-03 06:32 PM Re: KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
I have a script with multiple buttons, and I get both ENTER and ESCAPE functionality. (When in the order I listed in the initial posting.)

FWIW.

(I think the button in question had to be the last one added to the form. If so, then it would again lead us to see that this is inconsistent internal behavior.)

The order of assigning attributes to an object should not matter, should it?

-Crazy Eddie

[ 03. January 2003, 18:36: Message edited by: Crazy Eddie ]
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90783 - 2003-01-03 06:36 PM Re: KixForms "Feature"
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
When I add a second button to the script, it then behaves as explained: a button only has the Cancel or Default property depending on which was set last. I cannot get a form with 2 buttons to have one button as Default and Cancel.

[EDIT]
After reading Eddie's edit it appears he is correct. You can have a button as Default and Cancel if it is the last button added. I got that functionality when I moved the button that I set those properties on to the bottom of the script.

-Ben
http://www.rgcweb.org/kix

[ 03. January 2003, 18:40: Message edited by: Ben Dulaney ]

Top
#90784 - 2003-01-03 06:37 PM Re: KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Add the button in question last.
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90785 - 2003-01-03 06:44 PM Re: KixForms "Feature"
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
It might be because kixforms always does a setfocus to the last control added. But i was playing with this script here where just before the form is displayed, i setfocus to the textbox and i think it doesn't work anymore.

code:
BREAK ON

$FORM = CREATEOBJECT("KIXTART.FORM")

$TEXTBOX = $FORM.TEXTBOX
$TEXTBOX.LOCATION = 10,10
$TEXTBOX.RIGHT = $FORM.CLIENTWIDTH-10
$TEXTBOX.BOTTOM = $FORM.CLIENTHEIGHT / 2

$BUTTON1 = $FORM.COMMANDBUTTON("BUTTON1")
$BUTTON1.CENTER
$BUTTON1.TOP = $TEXTBOX.BOTTOM+10
$BUTTON1.ONCLICK = '$$=$$FORM.MSGBOX("BUTTON1","")'

$BUTTON2 = $FORM.COMMANDBUTTON("BUTTON2")
$BUTTON2.CENTER
$BUTTON2.TOP = $BUTTON1.BOTTOM+10
$BUTTON2.ONCLICK = '$$=$$FORM.MSGBOX("BUTTON2","")'
$BUTTON2.DEFAULT = 1
$BUTTON2.CANCEL = 1

$FORM.SHOW
$TEXTBOX.SETFOCUS

WHILE $FORM.VISIBLE
$ = EXECUTE($FORM.DOEVENTS)
LOOP


Top
#90786 - 2003-01-03 06:51 PM Re: KixForms "Feature"
Bonji Offline
Starting to like KiXtart

Registered: 2001-09-28
Posts: 169
Loc: Virginia
That makes sense. I'll be able to sleep soundly at work now [Cool] .

-Ben
http://www.rgcweb.org/kix

Top
#90787 - 2003-01-03 06:54 PM Re: KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Ok. That does make sense why it works/doesn't work/works again. [Smile]

Back to an original question:

Why can't a button accept both Default and Cancel, and keep those properties?

Thanks for the help Shawn!
-Eddie
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90788 - 2003-01-03 07:05 PM Re: KixForms "Feature"
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
To be honest - i think that there are two different approaches to flagging a button as being the default button ... one approach is mutually exclusive with the cancel button and the other is not.

I implemented the only approach I knew of (at the time) which is the mutually exclusive one. Now that I'm aware of an alternate approach - think we can implement a dual button in an upcoming release.

Specifically, every control has what is called an CONTROLID and there are a couple of well-known ID's ... ID_OK and ID_CANCEL are two of them. The approach kixforms uses is to set the button as either ID_OK or ID_CANCEL depending. But its not possible to set a button to both. The other approach circumvents the ID to identify the DEFAULT button - so now a button may be both - but I have yet to actually code and try it out.

Top
#90789 - 2003-01-03 07:10 PM Re: KixForms "Feature"
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Shawn,

After thinking about this more, I am not sure that we NEED both features. I'd be happy setting the cancel attribute, and ensuring my "default" button had focus before showing the form.

IOW, don't kill yourself on this item, just for me. [Big Grin]

[EDIT]
Oh, and thanks for the detailed explaination about how it works! [Smile]

[ 03. January 2003, 19:13: Message edited by: Crazy Eddie ]
_________________________
{Insert your favorite Witty Tag Line here}

Top
#90790 - 2003-01-03 07:53 PM Re: KixForms "Feature"
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Not problems - im killing myself on some other self-inflicted items right now (aka build 37 with custom draw buttons) ... but I still think this dual button feature is something that would be very usefull so will be giving it a go.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 764 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.147 seconds in which 0.067 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org