return in field activates default button

Ken Ray kray at sonsothunder.com
Fri Jul 27 15:54:21 CDT 2007


On Thu, 26 Jul 2007 22:54:29 +0200, Klaus Major wrote:

> Hi Ken,
> 
>> On Thu, 26 Jul 2007 20:31:47 +0200, Klaus Major wrote:
>> 
>>> Recipe:
>>> 1. Create a new stack
>>> 2. Add a field (with NO script of any kind!)
>>> 3. Add a "default" button with script:
>>> on mouseup
>>>   close this stack
>>> end mouseup
>>> 4. Write a line in the field and then hit return to create a new line
>>> in the field
>>> 5. Boom, the button gets triggered somehow and the window closes
>>> 6. Big fun! You're licked, if you did not save before ;-)
>> 
>> Doesn't happen to me, Klaus... and I've put in a breakpoint before the
>> "close this stack" and checked all the front scripts and it just works
>> properly.
>> 
>> MC IDE 2.8.2, Engine 2.8.1 build 471.
> 
> thanks for testing.
> 
> Damn, but this happens to me from time to time and I am NOT dreaming ;-)

No you're right, Klaus, because it just happened to me. I traced it to 
the MetaCard Menu Bar that was inserted as a library. There are traps 
there for returnInField and enterInField which checks a doClick() 
function that checks for the defaultButton:

function doClick
  switch
  case word 1 of the name of the target is "button" and the style of 
the target is not "menu" and not the autoArm of the target
    click at the loc of the target
    break
  case the defaultButton of this card is not empty
    click at the loc of the defaultButton of this card
    break
  default
    return false
  end switch
  return true
end doClick

I also found out why it had previously not happened to me - for some 
reason, in order for "the defaultbutton of this cd" to return a 
non-empty value, the button that has its default property set to true 
must be in a group (it doesn't have to have the backgroundBehaviour 
turned on). I'm assuming that when you ran into this problem, your 
default button was in a group, right?

This is a bug, pure and simple. Now whether it's a *functional* bug 
(i.e. "the defaultbutton of this cd" should return a value even if the 
default button is not in a group as the docs state), or whether it's a 
*documentation* bug (where they should explain that the button must be 
in a group for it to register), is anyone's guess. 

Personally I think it's a functional bug, but I would also like the 
mctools changed so that it doesn't automatically trigger the button on 
returnInField if the field is supposed to accommodate multiple lines of 
text (perhaps something related to whether the vScrollbar is shown, or 
if not if the formattedHeight is less than the height of the field, 
etc.).

Anyway, at least it's been found. Klaus do you want to do the honors 
and log the bug? Or would you like me to do that?


Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


More information about the metacard mailing list