Two revlets on a page

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Two revlets on a page

Post by cborn » Mon Dec 20, 2010 7:07 pm

Not sure if this is the right place, but is it feasible to have two revlets on the same webpage and have them able to interact? I want to place two elements of my revlet in disparate places on the page, to account for the other elements on the page and overall usability.

Alternately, if I install the server CGI on my host, can I use that to interact with a revlet on the page. I have a tight deadline and I'm trying to avoid having to re-code everything.

Thanks!

carly

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Mon Dec 20, 2010 9:10 pm

Hi Carly,

I did that a while ago and used Jaqueline Landman's description, which I cant find at the moment.

What I did was a teststack with a substack and show them next to each other on a page. Then you can send commands from the main stack to the substack.
http://berndniggemann.on-rev.com/stackandsub/

I append the stack and the index.html.

The trick is to configure the index.html manually so that the stacks appear next to each other or wherever you want. Have a look, I think you figure that out faster than I can explain it. You just copy the upper part (the automatic part) and replace the part that places the stack onto the browser page.

Don't you like deadlines? :)

regards
Bernd

Edit: I appended the original stack and substack, forgot that. I think the only difference is that I played a bit more with the blendlevel compared to the revlet.
Attachments
doppeltstack.rev.zip
(2.65 KiB) Downloaded 292 times
stackandsub.zip
(16.43 KiB) Downloaded 260 times
Last edited by bn on Mon Dec 20, 2010 10:11 pm, edited 1 time in total.

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Mon Dec 20, 2010 9:24 pm

Bernd,

This is brilliant, thank you! I think I get the idea and can easily incorporate this into my project. You are my hero! : :D

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Mon Dec 20, 2010 10:12 pm

Hi Carly,

I forgot to upload the original stack.

I uploaded it to the above post with the link to the revlet.

regards

Bernd

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Tue Dec 21, 2010 11:57 pm

Bernd,

So I've been having trouble with this. I got the two revlets to appear on the same page, and they load consistently. The substack revlet is a single button whose only job is to call the mouseup of a submit button in the main stack. Sadly, I can't get it to work.

This particular submit button does a whole lot, using the EnhancedQT external and then a POST command with custom HTTP headers to send the final file that it creates to a server. When I click the button by hand, it works great. When I try to call it from the substack button, very little of it works. Not even the first line of the script, which is

Code: Select all

set the visible of fld "Submitting" to true
:?: :?:

I've attempted to load the same externals into the substack, but that doesn't really explain why the simple line above doesn't work. I've also tried specifying the defaultstack property of the substack to be the mainstack. But no go. :?:

Right now, the substack button code is:

Code: Select all

on mouseUp
   go stack "LL Feedback Recorder"
   send "mouseup" to btn "Submit" of stack "LL Feedback Recorder"
end mouseUp
Do you have any tips on what I could try next?

Thank you in advance!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Wed Dec 22, 2010 12:25 am

Hi Carly,

I just tried to send "mouseUp" from the substack to a button on the main stack. It did not work.

Then I took the main part of the mouseUp handler and put it into a separate handler within the button script.
Actually I scripted the two buttons in the stack I posted that hide the field on the mainstack and show the field.
The script I made was

Code: Select all

on hideMe
   hide field 1
   put the script of me into field 1
end hideMe
And I made a button on the substack with the script

Code: Select all

on mouseUp
   send "hideMe" to btn "bHideField" of stack "doppeltstack"
end mouseUp

This worked in the revlet. Apparently the revlet does not like send "mouseUp". But a revlet can send a message across the stacks. No need to actually go there.
You might try something analogous to the above and see if it works. That would be the fastest way.

Alternatively you could move your handler into the card/stack script and again do a

Code: Select all

send "myHandlerName" to card/stack xyz
.

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Wed Dec 22, 2010 12:32 am

Hi Carly,

a little more testing shows this in the script of the button on the substack:

Code: Select all

on mouseUp
   send "mouseUp" to btn "bHideField" of card 1 of stack "doppeltstack"
end mouseUp
Apparently the mouseUp wants the full path, including the card. Which is always a good idea anyways.

Kind regards
Bernd

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Wed Dec 22, 2010 4:59 am

Bernd,

I had tried sending the message to the specific card like you suggest in your last post. But that does not have much effect.

I will try moving the script to the card and see what I get.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Wed Dec 22, 2010 9:45 am

Hi Carly,

I upload the little teststack with the substack that shows that sending a message from the substack to the mainstack works. There must be something other than the simple send command that is not working?

It has the stack/substack as .rev stack, the revlet and the test.html page.
should be working out of the box locally.

Kind regards

Bernd
Attachments
doppeltstack13.zip
(19.88 KiB) Downloaded 284 times

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Wed Dec 22, 2010 4:04 pm

Bernd,

Thanks for the samples. I think I have all of the syntax right, but what seems to be stalled is the use of the EQT bundle. A call to launch an Applescript app works later, but it doesn't have all of the right data because the EQT is not parsing the files that it's supposed to.

Like I said, even the first line of the mouseup on the mainstack

Code: Select all

set the visible of fld "Submitting" to true
is not done. Yet a call to an external app in a command further down the chain is done.

I don't think it's consistent, what works and what doesn't. I've tried making sure that the external is loaded in the substack, too. As well as setting the defaultstack to the mainstack. Nothing produces different results.

I guess I will need to rethink my layout to accommodate only one button. :(

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Wed Dec 22, 2010 4:28 pm

Correction:

It seems the root of the problem may be that when called from the substack button, the commands in the mainstack are not pulling data from the array. When the button on the mainstack is clicked itself, everything works swimmingly.

So it seems to be about context. I've tried setting the defaultstack of substack to be the mainstack. But maybe I'm not doing that right? This is what I have:

Code: Select all

 set defaultstack to "LL Feedback Recorder"

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: Two revlets on a page

Post by bn » Wed Dec 22, 2010 5:50 pm

Hi Carly,
set the visible of fld "Submitting" to true
did you try

Code: Select all

set the visible of fld "Submitting" of card x of stack y to true
?

What I would try in the btn handler:

Code: Select all

on mouseUp
  push card -- remember where we came from
  go card x of stack y
  -- do your commands
  -- more commands
  -- in case you want to be back where you came from
  pop card
end mouseUp
This is not tested but should work. I always have trouble with setting the default stack so I really dont use it. Maybe that would work also.
In the above code you actually are in the mainsack when you go there.

good luck

Bernd

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: Two revlets on a page

Post by cborn » Thu Dec 23, 2010 3:35 pm

Hi Bernd,

I did try

Code: Select all

set the visible of fld "Submitting" of card x of stack y to true
, but it behaved no differently.

I've had to move on to plan B for this particular version of the software. Students and teachers need to be using this starting Jan 3rd!

When i get a change, I'll probably come back to this and see if I can get it to work. But for now, I've just rearranged the elements on the webpage so that I can keep the Submit button near the rest of the revlet objects.

Thanks for your help!

Post Reply