stack as button

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

stack as button

Post by RobertC » Fri Dec 21, 2012 10:05 pm

I want to make a standalone stack such that it runs a handler when the mouse is clicked in a button, even when the stack is NOT the currently active application.
Normally, to make a button do something the first click will activate the application and only the second will push the button.

Can I circumvent the activation click?

Robert.
The Old Rant Robert.

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

Re: stack as button

Post by Simon » Fri Dec 21, 2012 10:18 pm

Instead of a button could you use resumeStack?

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

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: stack as button

Post by doc » Sat Dec 22, 2012 4:46 am

Hey RobertC...
I can test only on Windows currently, but if I understand your question correctly and both O/S's function the same in this regard, then adding a card script like this seems to work:

Code: Select all

on mouseDown
      if the clickLoc is within the rect of btn "NamedWhatever" then
         send mouseUp to btn "NamedWhatever"
      else
         --- do something else, nothing at all or pass the message
   end if
end mouseDown
HTH,
-Doc-

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

Re: stack as button

Post by Mark » Sat Dec 22, 2012 5:12 am

Hi Robert,

You could set the systemWindow of your stack to true.

Kind regards,

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

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: stack as button

Post by doc » Sat Dec 22, 2012 5:38 am

Mark,
Out of curiosity, on a Mac isn't the z-order of a systemWindow always at the top level, blocking all other windows and dialogs from the same stack, just as it does with a Windows based app?

Regards,
-Doc-

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

Re: stack as button

Post by dunbarx » Sat Dec 22, 2012 5:59 am

The dictionary says that setting the systemWindow to "true" has no effect in OSX. This is not correct, and a note by WWaldman makes the point.

If you make a stack with a button that, say, puts a random number into msg, and set the systemwindow to "true", then that stack will float above all others, and even though the message box is hidden when another app is in front, clicking on the button will reveal a new number in msg when you return to LC.

So it seems that Mark's idea is the cleanest.

Craig Newman

RobertC
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sun Feb 04, 2007 3:43 pm

Re: stack as button

Post by RobertC » Sat Dec 22, 2012 9:11 am

Thanks everyone for your most helpful replies. I'll try to give some comments:

First a little more background: with the advent of Lion the PPC emulator went and I lost Golive. I have for over a year now tried to get its functionality back, with little result. I now have to use a simple editor like BBEdit to write html, and have to do so in code!
Typing in markup is a real pain, but BBEdit is scriptable so I wrote a set of Applescripts to help. What I want now is a "palette" of buttons that sits next to the BBEdit window. Clicking a button on the palette should then result in the insertion of html markup into the BBEdit window, but (a) I don't want to click twice, and (b) after the click I want to be back in the BBEdit window.

(1) Simon's proposal to use resumestack works and solves the problem. Though it means that all I have at my disposal is the mouselock, so I then have to find out which button, but that is easy as Doc points out.

(2) Doc's proposal does not work at the first click however.

(3) Mark's proposal does not work. It is however useful as a tip because it floats the window, which I may or may not want, I have not decided yet.

(4) Dunbarx remark is correct: systemWindow does have an effect on OSX.

Using Simon's simple proposal the stack now works as follows:
-- the click runs the resumestack handler, since it activates the stack.
-- that handler then finds out where the click occurred and sends a message to the corresponding button.
-- the button then executes an applescript that makes BBEdit insert the relevant html markup using "tell application BBEdit...".
-- it is crucial that the applescript ends with the statement "activate" before the "end tell", so that BBEdit takes the focus again (and the stack goes into suspension. I could therefore also do something at suspendStack).

So I have what I want, thank you all again.
:-)

But I keep regretting the demise of Golive. I have tried Dreamweaver of course, but it is simply not up to the task.
:-(
The Old Rant Robert.

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: stack as button

Post by shaosean » Sat Dec 22, 2012 11:43 am

You can always try out SheepSaver to see if GoLive works for ya..
http://www.emaculation.com/forum/viewto ... d5e08b4861

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

Re: stack as button

Post by Mark » Sat Dec 22, 2012 12:49 pm

Hi,

Why doesn't my solution work? It does exactly what you want.

Kind regards,

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

doc
Posts: 148
Joined: Fri Jun 09, 2006 4:30 pm

Re: stack as button

Post by doc » Sat Dec 22, 2012 2:10 pm

So I have what I want, thank you all again.
:)
...and since I've never used resumeStack before, I have learned something new in your process.
Always a good thing. :)

Regards,
-Doc-

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

Re: stack as button

Post by dunbarx » Sat Dec 22, 2012 4:31 pm

Hi.

As Mark said, why not? The simple example I gave, where a message was sent to LC while one was in another app, ought to be expandable to any degree. It is as if LC was placing a universal palette over the entire desktop, the app in front not having any influence at all.

How did you test? How did it not work?

This property of LC seems FULL of possibilities, as one could be in excel, for example, and use a LC stack as access to functionality that uses that spreadsheet directly, perhaps by reading the excel data on the fly, but never leaving excel at all. It is as if LC is present at all times in any other application.

Craig Newman

Post Reply