Contextual (popup) menus and their options

2008-08-25 Thread Mark Stuart
Bonjour Eric,

If only I would look in the Documentation for this command, I would not
waste your time.

Thank you for explaining, your time, and your grace. :-)

 

Regards,

Mark Stuart

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Contextual (popup) menus and their options

2008-08-25 Thread Eric Chatonet

Bonjour Mark,

Sorry if I was not clear enough.
As I said, the selectedChunk, that returns a chunk expression  
describing the location of the text selection or insertion point, is  
always something like char 4 to 3 of field 1 (insertion point is  
placed after char 3 but there is no text selection), char 4 to 4 of  
field 1 (char 4 is selected), char 1 to 4 of field 1 (char 1 to 4 is  
selected).


word 1 of the selectedChunk = 'char'
word 2 of the selectedChunk = 
word 3 of the selectedChunk = 'to'
word 4 of the selectedChunk = 
etc.
These integers are those that interest us :-)

'char 4 to 3 of field 1' -> '2 < 4' ->' word 2 < word 4' -> insertion  
point but no selected text
'char 1 to 4 of field 1' -> '1 < 4' ->' word 2 > word 4' -> selected  
text


Why word 4 is less than word 2?
A simple convention to distinguish when the insertion point is in the  
field if there is some selected text also or not.
When word 4 is less than word 2, this means that the insertion point  
is in the field after char 'word 4 of the selectedText' but there is  
no selected text.
If word 4 is more than word 2, this means that char 'word 2 of the  
selectedText' to 'word 4 of the selectedText' are currently selected.


See selectedChunk, selectedField, selectedText in the docs.

Le 25 août 08 à 00:57, Mark Stuart a écrit :

But I'm not sure what this part of your script does, what it is  
checking

for?



   if word 4 of the selectedChunk < word 2 of the selectedChunk then



Why word 4 and why word 2?

And why word 4 is less than word 2?


Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Contextual (popup) menus and their options

2008-08-24 Thread Mark Stuart
Bonjour Eric,

 

Put your script into my field, and it's working, thank you.

But I'm not sure what this part of your script does, what it is checking
for?

 

   if word 4 of the selectedChunk < word 2 of the selectedChunk then

 

Why word 4 and why word 2?

And why word 4 is less than word 2?

Are these the menu items?

And I'm assuming the selectedChunk is testing for any selected text.

 

Regards,

Mark Stuart

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Contextual (popup) menus and their options

2008-08-24 Thread Eric Chatonet

Bonjour Mark,

An Edit menu, if you want to stay compliant with all platforms  
guidelines, should always show the 'Cut, Copy, Paste' trilogy as a  
minimum.
Of course, you can disable the menu items you don't want the user to  
use but they *must* be there with their usual shortcuts :-)
So in your case, just build the menu on-the-fly at mouseDown and  
disable the Copy item according to the value of the selectedChunk:
It's always something like char 4 to 3 of field 1 (insertion point is  
placed after char 3 but there is no text selection), char 4 to 4 of  
field 1 (char 4 is selected), char 1 to 4 of field 1 (char 1 to 4 is  
selected)...


on mouseDown pButton
  local tMenu
  -
  if pButton = 3 then
if the selectedField = empty or target = empty then exit mouseDown
if the short name of the selectedField = the short name of the  
target then

  -- it's the right field
  put "(Cut/X,Copy/C,(Paste/V,-,Select All/A" into tMenu
  -- easier to build the menu using commas
  replace comma with cr in tMenu
  -- cut and paste are always disabled
  if word 4 of the selectedChunk < word 2 of the selectedChunk then
put "(" before line 2 of tMenu
-- there is nothing to copy: copy is disabled
  end if
  put tMenu into btn "MyMenu"
  popup btn "MyMenu"
end if
  else pass mouseDown
end mouseDown

Of course you'll set the traversalOn of the popup menu button to  
false to avoid text deselection.


Le 24 août 08 à 22:56, Mark Stuart a écrit :


Hi All,



I have a contextual menu (popup) on a text field with several  
options. One

of them is Select All.

This allows the user to select all the text in this field.

If the user actuates the contextual menu again, the Select All  
option should
still be there, but also a new option is selectable - Copy - copies  
all

selected text to the clipboard.



So the question is, how do I detect if text is selected in a text  
field, and

then dynamically "change out" the menu option by adding "Copy" to it?



Regards,

Mark Stuart



Best regards from Paris,
Eric Chatonet.

Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: [EMAIL PROTECTED]/



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Contextual (popup) menus and their options

2008-08-24 Thread Mark Stuart
Hi All,

 

I have a contextual menu (popup) on a text field with several options. One
of them is Select All.

This allows the user to select all the text in this field.

If the user actuates the contextual menu again, the Select All option should
still be there, but also a new option is selectable - Copy - copies all
selected text to the clipboard.

 

So the question is, how do I detect if text is selected in a text field, and
then dynamically "change out" the menu option by adding "Copy" to it?

 

Regards,

Mark Stuart

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution