Coding "Edit" Menu Items

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
Whenever an application is given a MenuBar and the "Standard Items" are included, there is an Edit section that includes "Redo," "Undo," "Cut," "Copy," "Paste," and "Select All."

Generally, this would be applicable to text editing controls, but I've heard a little about people using them with objects.

I generally do very basic coding (VB or C#), and I've never dealt with any of this.

Related to this ability is the ability to accept "Drag-n-Drop," or it seems like it fits into the same voodoo category to me.

Where could I find something simple on how to (redo, undo, cut, copy, paste, select all, dragNdrop) with objects?

Are events typically set up that enable and disable these menu items? For example, if nothing is selected, the Cut and Copy menu items are disabled. If there is data on the clipboard, the Paste menu item is enabled. I understand for the case where someone selects something, the programmer writes code to count how much was selected, then enables an item, but this seems like Geiko Caveman code. The activation of these menu items should respond to events.

Could anyone point me to something like that?
 
The problem is, the menu items don't know what events will trigger them being enabled or disabled. It depends on the application. You'll have to handle catching the events for enabling/disabling the items in whatever control you're using with that functionality.
 
The problem is, the menu items don't know what events will trigger them being enabled or disabled. It depends on the application. You'll have to handle catching the events for enabling/disabling the items in whatever control you're using with that functionality.
Thanks for your response. All I'm looking for are "best practice" guidelines, website tutorials, etc.

I've done very little event handling other than what comes with controls and this never seems to be covered in any of the books I look into.

If anyone else has any input, suggestions, or ideas, please respond.

Thanks!
 
You can't really have any "best practice" guidelines because there's not one set way to do those things. The Standard Items in the menubar and toolbar don't know anything about how data will be input. How you disable/enable those controls depends on how you're inputting data. It could be the keyboard, it could be an on-screen keyboard with a mouse or other controller, it could be voice recognition software, etc.
 
Back
Top