ComboBox

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

ComboBox

Post by phaworth » Sun Mar 07, 2010 1:42 am

OK, so I think this is weird.

I place a combobox on a card, The property inspector says it's called button "xyz". If I type a new value into it and tab out of it, a closeField event is generated and if my code looks at the name of the object within the closeField event, it has magically changed itself into field "xyz", not button "xyz".

If I select an item from the combobox, I get a menuPick event and the button then announces itslef as button "xyz".

Why does the object announce itself as a field in closeField and a button within menuPick? Do we now have schizophrenic objects in Rev?

This is a big problem for my code. IS there a way I can discover that what announces itself as a field is really a button in disguise?

Pete.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: ComboBox

Post by Mark » Sun Mar 07, 2010 10:12 am

Hi Pete,

A combobox is indeed a button with a field. A closeField handler would be rather inconsistent if it were triggered by a button. A menuPick message can only be sent by a menu button. When a programming environment becomes more complex, such problems seem inevitable. No matter how you change the behaviour of a combobox, it will always me inconsistent in one way or another.

To solve you problem, use a unique name for the combox and check the short name of the target in your closeField and menuPick handlers.

Code: Select all

on closeField
  put the short name of the target into myName --> unique name
  -- etc
end closeField

on menuPick theItem
  put the short name of the target into myName --> unique name
  -- etc
end menuPick
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: ComboBox

Post by phaworth » Sun Mar 07, 2010 7:34 pm

Thanks Mark.

The menuPick isn't a problem since the object reports itself as what it really is - a button - and I can discover what type of button by examining it's properties. All my existing code works just fine for menuPick on a combobox.

I agree that complex programming environments lead to difficult choices, it just seems really strange to me that an object would claim to be something it isn't. I have generalised routines to handle many events, including closeField, which rely on being able to correctly identify what type of object I'm dealing with from one or more of its properties. They were written to be reusable in any other application I might develop so relying on hard coded object names won't work for me. I guess I will have to add some code to handle the fact that field "xyz" isn't really a field at all but a combobox If it reported itself as a button, my existing code would identify it as a combobox, just like it does in menuPick, and since it generated a closeField event, the user must have typed a new value into it.

I'm also taking a look at Jerry Daniels new combobox object.

Now that I've run into this, are there any other circumstances where an object identifies itself as something it really isn't or is this unique to comboboxes?

Pete

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: ComboBox

Post by Mark » Sun Mar 07, 2010 7:50 pm

Hi Pete,

I don't know of any additional issues similar to this one.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: ComboBox

Post by phaworth » Sun Mar 07, 2010 11:13 pm

Glad to hear that, thanks Mark.

Too many changes in my code to deal with comboboxes so I've implemented my own solution. It's a group with an option menu button, a hidden field initially positioned behind the option menu and a small button with a plus sign on the corner of the option menu. When the plus sign is clicked, the field is unhidden and repositioned immediately below the option menu. The user keys in the new value, closeField deals with all the updating needed by my app, hides the field and puts it back behind the option menu. Takes a little more screen space than a combobox but works perfectly with my existing code.

Pete

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: ComboBox

Post by FourthWorld » Mon Mar 08, 2010 3:22 pm

I just ran this in a combobox in v4.0:

on closefield
put the name of me
end closefield

I got:

button "New Button"
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: ComboBox

Post by Mark » Mon Mar 08, 2010 3:25 pm

Richard,

That won't work when you have a generic handler at card or stack level.

Try this:

Code: Select all

on closefield
     put the name of the target & cr & the name of me
end closefield
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: ComboBox

Post by FourthWorld » Mon Mar 08, 2010 4:10 pm

Good sleuthing.

Oddly enough I couldn't find a report for this in the RQCC so I added one:
http://quality.runrev.com/qacenter/show_bug.cgi?id=8653
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: ComboBox

Post by phaworth » Mon Mar 08, 2010 6:35 pm

Thanks for following up on this and submitting the bug report. I had also found this anomaly. In my generic closeField handler (which uses "the target"), the combobox reports itself as a field and in the closeField handler attached to the combobox itself (which uses "me"), it says it's a button. All of which makes it even more difficult for me to deal with so I've settled on my own combobox design I mentioned a couple of posts ago. I improved the design to take up less real estate on the screen - the user input field is hidden behind the option menu until needed when I hide the option menu and show the field. Vice Versa when the field processing is complete.

IS there a way to subscribe to bug reports so you can keep track of what happens with them?

Thanks,
Pete

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: ComboBox

Post by FourthWorld » Mon Mar 08, 2010 8:00 pm

Yes: each report record has a way to add yourself as a CC, so you'll get notification via email for any changes to the report. You'll need to create an account there, but it only takes a minute to do.

Reports also allow votes. Each user is given 100 votes, and can apply to up five of those to any given but report or feature request.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”