How to detect (event) Browse/run modes?

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
ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

How to detect (event) Browse/run modes?

Post by ale870 » Thu Oct 16, 2008 8:27 am

Hi,

using "tools palette" i can switch between pointer mode (design) and Run (browse).
Is there any even (on....) to detect this switch in a stack?

I need to enable some functionalities (revBrowser) only when the program is running (Tool->Run) and disable the component at design-time.

I tried to search some information in the forum, but I cannot find anything useful since I don't know exactly which keywords I need to search: browse? Run? Design? Pointer? etc... :?

Thank you! :D

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

Post by Klaus » Thu Oct 16, 2008 8:37 am

Hi ale870,

there is no built-in solution for that, but you can check "the tool", see the docs.

Code: Select all

...
if the tool = "pointer tool" then
## edit mode
else
## browse tool
end if
...
Best

Klaus

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Thu Oct 16, 2008 9:06 am

But where can I put that code?
I have no event, I need to make a timer-based system (e.g. check every 5 seconds) to verify in which status is the software?

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

Post by Klaus » Thu Oct 16, 2008 10:01 am

ale870 wrote:But where can I put that code?
I have no event, I need to make a timer-based system (e.g. check every 5 seconds) to verify in which status is the software?
Hi ale870,

yes, you will need to check regularly.
Quick thought:
Put a script into your stack and call it on preopnestack or even manually.
Something like:

Code: Select all

command check_the_tool
  if the tool = "pointer tool" then
    ## EDIT mode, do your stuff here
  else
    ## BROWSE mode, do your other stuff here
  end if
  send "check_the_tool" to me in 2 secs
end check_the_tool
See these terms in the docs:
send...in...
pendingmessages

To be honest I still do not get what you are after... :-)
Even with some functionalities disabled, you can still enable them again since you are in the IDE!!!???


Best

Klaus

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Thu Oct 16, 2008 1:17 pm

Hi,

you can handle the newTool message in a frontscript. Do not forget to pass it.

Cheers,

Malte

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Thu Oct 16, 2008 1:39 pm

Well,

my problem is I'm working with revBrowser and I need to close it at design-time.

@malte can you better explain me how can I do with your system?

Thank you!

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Thu Oct 16, 2008 5:14 pm

Answering for malte - I believe he means something along the following lines:

Make an object (can be anything - I would say a button set to invisible, for example).

Give it the script

Code: Select all

on newTool tTool
   switch tTool
      case "browse"
        answer "browse"
        --close revBrowser and do what you need in browse mode
        break
      case "pointer"
        answer "pointer"
        --do what you need to do in pointer mode
        break
   end switch
   pass newTool   
end newTool
note you should not include an "on mouseUp" handler.

In the message box type

Code: Select all

insert script of button "<your button name>" into front
The script of the (hidden) button is now a "frontscript" which means it will receive messages before the engine, hence you need to pass the newTool message to allow the engine to react to it.

To remove the script, quite logically, you use

Code: Select all

remove script of button "<your button name>" from front

ale870
Posts: 250
Joined: Tue Apr 22, 2008 9:17 am
Contact:

Post by ale870 » Thu Oct 16, 2008 5:23 pm

Yes! This is the "final" answer I was looking for!

Thank you to everyone for your help! :D

Post Reply