ComboBox Menu Script in Datagrids

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
Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

ComboBox Menu Script in Datagrids

Post by Gage » Wed Sep 18, 2013 5:49 pm

Hello,

I have some ComboBox Menu-style Option Menu buttons in a DataGrid form. They are supposed to do some things on MenuPick, but no message is ever being sent to the object script when the objects are being clicked. It appears that there is some kind of internal exception or something related to the message path, because when I place a Breakpoint in the object script, it never runs, whether on MenuPick or even just on MouseUp/MouseDown.

Looking for possible reasons why this object does not function normally inside a DataGrid. I have posted this question before, and have conducted multiple detailed tests to ensure that my script operates correctly OUTSIDE a DataGrid. It appears to simply be due to the fact that the object is located in the DG.

Any suggestions/ special loopholes I need to be aware of with DGs to make this function right?

Thanks!
Phil E.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: ComboBox Menu Script in Datagrids

Post by dunbarx » Wed Sep 18, 2013 6:36 pm

Hi.

So if, in the combo box script, you have simply:

on menuPick
answer the target
end menuPick

You get nothing?

Craig Newman

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: ComboBox Menu Script in Datagrids

Post by Gage » Wed Sep 18, 2013 8:31 pm

On my current project stack, that is correct.

I opened a brand new stack, and created a very bare-bones DataGrid form, containing only a ComboBox Menu button in the Row Template, and tried the same procedure. It did not work, either. Neither MouseUp nor MenuPick is being received by the object. I will attach the new test stack I used.

Thanks!
Phil E.
Attachments
DG ComboBox Test.livecode.zip
(4.82 KiB) Downloaded 281 times

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: ComboBox Menu Script in Datagrids

Post by Klaus » Wed Sep 18, 2013 9:39 pm

This works:

Code: Select all

on menuPick pItemName
     answer the target 
end menuPick
This doesn't:

Code: Select all

on menuPick pItemName
   switch pItemName
     answer the target 
   end switch
end menuPick
8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: ComboBox Menu Script in Datagrids

Post by dunbarx » Wed Sep 18, 2013 11:12 pm

Klaus.

What I said.

The OP stated that the combo worked fine alone, but not embedded in the DG template. The menuPick handler he used therefore must either have declared "pItemName" as a case in its structure, or gone the way we both suggested, using the message bare bones. What changed when it was stuck into the form is the question.

Craig

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: ComboBox Menu Script in Datagrids

Post by Gage » Thu Sep 19, 2013 12:26 am

Klaus,

I see what you mean, but it actually did NOT work on my test stack when I did it that way.

On my actual stack, however, I had a different effect. BOTH methods popped up the answer box, assuming that I provided the word "default" before the "answer the target" command within the switch statement.

HOWEVER, when I use a breakpoint in the code where this is written, nothing happens. Meaning that the answer box pops up, but somehow does not execute the script to do so, if that makes any sense at all. The script just never runs, and the breakpoint is never activated, even though the answer dialog pops up as it should.

I made a few small tweaks to the test stack and will include it. I give my assurances that, at the moment, the actual stack is running the same test method for its own ComboBox Menu objects.

Best,
Phil E.
Attachments
DG ComboBox Test.livecode.zip
(4.84 KiB) Downloaded 257 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: ComboBox Menu Script in Datagrids

Post by Simon » Thu Sep 19, 2013 2:17 am

Ok Phil,
I'm getting somewhere with this.
For your breakpoint issue actually write the word "breakpoint" into the menuPick. Do not use the little red dot.

I still have nothing coming from the mouseUp but you don't need that.

In your menuPick you want pItemName not target. The switch/case is working.

Remember to always hit your Refresh DG after any script change

I am working with your first posted stack.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Gage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 224
Joined: Tue Mar 26, 2013 8:59 pm

Re: ComboBox Menu Script in Datagrids

Post by Gage » Tue Sep 24, 2013 7:01 am

Simon,

You are totally right about inserting the "Breakpoint" via text rather than by using the red dot. This is strange to me, but I'm going with it!

As for the pItemName part, you are totally right, there, too. I see now that it is indeed running, and I was finally able to view the script as it runs, so I can actually debug it!

I am now realizing that the switch I am using in the application I am solving all of these problems for has an unrelated problem to solve, namely, how to get the dgIndex of the ComboBox Menu to store into a variable for use.

Sorry for the lack of feedback at first, I took your advice and ran with it, forgot to look back and appreciate! So, thank you!

Best,
Phil E.

Post Reply