• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

Handle cut & paste in a dialog window

how should I handle cut & paste in a dialog windows edit text controls?

void do_edit_cmds(short the_item)
{
 
  switch( the_item )
  {
     case editUNDO:
        if(SystemEdit( the_item - 1) )
         ;
        break;
     case editCUT:
        if(SystemEdit( the_item - 1) )
        ;//SysBeep(10);
        break;
     case editCOPY:
        if(SystemEdit( the_item - 1) )
        ;
        break;
    case editPASTE:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editCLEAR:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editSELECT_ALL:
       if(SystemEdit( the_item - 1) )
       ;
       break;
    case editPREFERENCE:
       Handle_Preferences();
       break;    
 }
}
0
gailp
Asked:
gailp
1 Solution
 
boonstraCommented:
You want to use the routines DialogCut, DialogCopy, and DialogPaste, each of which takes a single parameter, a pointer to the dialog you want to cut/copy/paste from.

Without seeing more of your event loop, it is difficult to provide specific code.  Assuming you are talking about a modeless dialog, if you know that your dialog is the frontmost window when you enter do_edit_cmds, you can simply:

WindowPtr wind;

wind = FrontWindow();
switch (the_item) {
  case editCut:
    DialogCut(wind);
    break;
  case editCopy:
    DialogCopy(wind);
    break;
  case editPaste:
    DialogPaste(wind);
    break;
}

You do not need to provide the item being edited, as the DialogManager already knows that and does the right thing.

If it is possible that some other window is frontmost when you call do_edit_cmds, then you'll want to use something like:

  case editCut:
    if (IsMyDialogWindow(wind)) DialogCut(wind);
    break;

where IsMyDialogWindow is code you provide to determine whether wind is one of your dialogs.
0
 
gailpAuthor Commented:
This answer worked for me.

Thank You for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now