set the tool of a stack

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the tool of a stack

Post by jmburnod » Thu Apr 30, 2009 6:00 pm

Hi All,
I want set the tool of a main stack by a click to a btn of a substack and keep the browse tool for the substack

This script work well but you have maeby others ways more elegants

on mousemove --•• in the stack script of the main stack
global gLaCurTool
put "TestJLS 1.03" into LeMainStack
put "UnePalette" into LeSubStack
put the mousestack into LeCurStack
put the tool of this stack into bufTool
if LeCurStack = LeMainStack and bufTool <> gLaCurTool then
set the tool of this stack to gLaCurTool
end if
if LeCurStack = LeSubStack and bufTool <> "browse" then
set the tool of this stack to "browse"
end if
end mousemove

Thank for your help
Last edited by jmburnod on Thu Apr 30, 2009 8:40 pm, edited 1 time in total.

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

Post by Klaus » Thu Apr 30, 2009 6:37 pm

Bon soir jmburnod,

I'm not sure if I understand what you are looking for but maybe this helps:

If a stack is opened as a "palette" (looks like your substack "UnePalette" :-)
IS in fact a palette window, right?) then the "tool" of this stack will ALWAYS
be the browse tool!

(As you can see with the REV tools palette!)

So in this palette stack your button to change the "tool" could use this simple script:

Code: Select all

on mouseup
  choose pointer tool
end mouseup
And the rest will happen automatically :-)
(IF I understand you correctly!)

Anyway, that's the way you should implement a "tools" palette at all.

Au revoir d'allemagne

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the tool of a stack

Post by jmburnod » Thu Apr 30, 2009 8:34 pm

Guten Abend Klaus,

Und danke für deine hilfe.

Yes, you have understand perfectly my need.

I tested "choose pointer tool " but the tool of the substack change also to pointer (with revolution 2.9)

It work for you ?

Mit freudlischen grüssen von Genf

Jean-Marc

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

Post by Klaus » Fri May 01, 2009 1:06 pm

Ah, ein Schwyzer :-)

Bonjour Jean-Marc,

you need to open your substack as palette like:
...
go stack "UnePalette" as palette
...
to make it work.

Try this and come back if it does not work.

Remember to keep the GUI (Graphical User Interface) standards where a "tools" stack should be a palette window (like the REV tools palette).


Au revoir

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the tool of a stack

Post by jmburnod » Sat May 02, 2009 2:12 pm

Vielen dank noch einmal Klaus,

I try with "as palette" and i can set the tool for browse,image,select

but

the others change only after a selection of the tool on the revtool

Is there an "initPaintTool" or something like that ?

Jean-Marc

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

Post by Klaus » Sun May 03, 2009 11:52 am

Hi Jean-Marc,

sorry, don't understand what you are trying to do?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the tool of a stack

Post by jmburnod » Sun May 03, 2009 5:45 pm

Hi Klaus

Sorry for my poor english
I trying to do a toolpalette for paint an image on the main stack

The tool palette is open as palette and there is a fld with a list of tools

One clic on a line change the tool of the main stack

It work for some tools immediately (browse,image and pointer) but not for
brush, bucket, eraser and spray :

For exemple, the tool of the stack return "brush tool" but the cursor dont change and the brush dont work.

Jean-Marc

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

Post by bn » Sun May 03, 2009 6:31 pm

Jean-Marc,

try

Code: Select all

on mouseUp
   choose brush tool
   set the brush to 8
   --set the brushcolor to black
end mouseUp
or

Code: Select all

on mouseUp
   choose eraser
   set the eraser to 12
end mouseUp
for the cursor to change you have to set a brush etc on top of choosing the brush tool
regards
Bernd

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

Post by Klaus » Sun May 03, 2009 8:28 pm

YO! :-)

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

Post by bn » Sun May 03, 2009 9:00 pm

THANK YO! :)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

set the tool of a stack

Post by jmburnod » Mon May 04, 2009 7:27 am

YES,

bucket, brush, eraser and spray work fine now

many thanks

Jean-Marc

Post Reply