Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use setup-code in short-menu

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!

In the rightclick of textboxes I let popup a shortcut-menu with, among others, copy,cut,paste.
Onless there has been some text selected in the textbox copy and cut should be disabled, paste should be disabled once the clipboard is empty.
I did understand to manage some using from the menu : view -general options- setup.
But how can I in the procedure that popped up address code for the individual cut, paste and cut?

-Bart
 

Bart,

If you want code to execute for the individual commands, the Setup code is not the place to do it. Setup is code that runs when you first launch the menu, not when the user makes a selection.

To write code that executes when the user makes a selection, set the Results column (to the right of the Prompt) to either Command or Procedure, and write your code there. But why would you want to do that with cut, copy or paste?

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,
I think it's a good habit to disable Copy and cut once nothings has been selected from the control you let rigtclick-menu fire.
-Bart
 

Bart,

As far as I can see, that behaviour is built in if you use the standard Edit menu and the built-in bar numbers. But you're right that it doesn't work with shortcut menus. I have a shortcut menu in all my applications, and Cut, Copy and Paste are always enabled, even if there's no selection or the control is read-only.

I guess you could write a function that checks the control's ReadOnly and SelLength properties (and also checks to see if there is any text in the clipboard). You could call this function from the Skip For clause of the relevant menu bars.

Personally, I've never gone to the trouble of doing that. The behaviour is not perfect, but it's livable-with.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Bart,

Like Mike, I too have a cut/copy/paste/undo/redo section in my main menu, so I don't have to do the same thing in the rightclick menu. I reserve rightclick menus for items specific to that particular control. For example, Reset to Default, Clear, Help, etc.

If you leave cut/copy/paste in your main menu, it handles all of the enabling for you.

Ken
 
Ok,
Thanks for the replies.
Mike's solution makes most sense to me.
Ken, the reason why I want it to include is to let the user move the mouse as less as possible.
-Bart
 

Just to be clear ...

I do have a right-click menu, but I also have an Edit menu on the main menu bar. It's just that, in the case of the right-click menu, I don't worry about the cut, copy and paste commands being permanently enabled.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top