yet another Rev trick for Selections and Plugins
MisterX
b.xavier at internet.lu
Sun Nov 27 03:13:45 EST 2005
Hi everyone
It's a white morning here in luxembourg - I overslept to 7h30
and glad I did! Motivated to work in the object garage...
I was working on a new cool stack (a new group of renaissance
style stacks) and noticed I gave up something and didn't
notice how the answer was already under my nose!
I switched stacks and I noticed something was missing in
Rev... It's so simple, and while you learn to live with it in
rev really fast, it still is a sore in general productivity.
Bugzilla it? No, it's part of the job of the scripter to do
this or not... But in general, this selection trick is very
handy to have. And available since the 80's guis!
When you select something in a field in window 1,
Go to another window look something up, go back to window 1
and your selection is gone. Or, copy something, go paste it
in another window and when you paste, your selection in window
1 is gone!
And how often doesn't it happen to you?
The bigger the selection the more annoying too!
That's not the way selections work in any OS I remember...
But Rev allows us to manage this!
So I added this to my library stack and it works great!
I'll share the basic mechanism because it's the start for
the rest of the logic behind plugins.
Showing you how to make it work, instead of making
the stack ready is imoho the same as the difference
between giving a man a meal or teaching him how to fish...
This tip is medium-level but really easy to implement...
You should know how to make libraries, that is stacksinuse,
front or backscripts, and how the resume[stack] and suspen[stack]
events work.
The following script goes into the main stack script that
manages your windows or a startupscript or your personal
frontscript. Im sure it will be handy for other uses.
Note: If you paste it, make sure there isn't another
suspendstack or resumestack script you may overide in that
same script.
--
local xos -- use a global for more flex across libraries if needed
on SuspendStack
-- remember selection
put the filename of the topstack into thisstack
if the selectedchunk is not empty then
put the selectedchunk into xos[thisstack,lastselections]
end if
pass SuspendStack -- don't forget to pass the msg
end SuspendStack
on ResumeStack
-- reselect
put the filename of the topstack into thisstack
get xos[thisstack,lastselections]
if it is not empty then
try -- just in case it goes wrong
do "select" && it
end try
end if
pass ResumeStack -- don't forget to pass the msg
end ResumeStack
--
Exercise: implement this for resume and suspend events, field
selection switch (going from one field to another (harder),
and what about the selobj(s)!
Did I mention theres lots more applications?
--
For those interested in more evolved libraries that also remember the
selobjs, the control's props (and history of), resume and suspend orders and
stats, and more... It's all available already across TAOO.
cheers
Xavier
--
http://monsieurx.com/taoo
The Art Of Objects
More information about the use-livecode
mailing list