> On Oct 14, 2017, at 12:13 PM,ernie hilgers  wrote:
> 
> Message: 6
> Date: Fri, 13 Oct 2017 22:29:20 -0400
> From: ernie hilgers <[email protected]>
> To: [email protected]
> Subject: right click in text variable gets menu with cut copy paste
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=us-ascii
> 
> Hi all, 
> problem / request:
> A user of one of my database solutions on PC W7 4D v13.6 is complaining that, 
> in many of the alphanumeric fields, there is NO right click with subsequent 
> cut copy paste menu. 
> they absolutely refuse to use any keyboard short-cut, all must be done with 
> the mouse (they are absolutely adamant) . 

Upgrade to v14. It has a checkbox in the Property List for text fields and 
variables called “Context Menu” that does what you want. But it only works on 
text fields. So for date, time and numeric fields you still have to do all the 
work yourself. 

With need v14 because  you can turn on the “On Clicked” form event for fields 
now and then you can trap when a user clicks or right-clicks in a field. Here’s 
some code to make this work for date, time and numeric fields:. 

  // ===========================================
  // PROJECT METHOD: HandleContextualMenu

  // PARAMETERS: $1 = menu ref (optional)
  // $2 = method name (optional)

  // DESCRIPTION: Put this method in a form object and it will
  // respond to a right-click in the current object. 

  // Pass no paramters and it will do the default which is to support
  // Cut, Copy and Paste in the current object.

  // CREATED BY: Tim Nevels, Innovative Solutions ©2016
  // DATE: 4/1/16
  // LAST MODIFIED: 
  // ============================================

C_TEXT($1;$menuRef_t)
C_TEXT($2;$methodName_t)
If (Count parameters>=1)
   $menuRef_t:=$1
Else 
   $menuRef_t:=<>defaultRightClickMenuRef_t
End if 
If (Count parameters>=2)
   $methodName_t:=$2
End if 

C_TEXT($menuItem_t)
C_LONGINT($mouseX;$mouseY;$mouseButton;$start;$end)

If (Form event=On Clicked)
   GET MOUSE($mouseX;$mouseY;$mouseButton)
   If (Macintosh control down | ($mouseButton=2))  // right-click
        // determine enabled/disabled for Cut and Copy items
      GET HIGHLIGHT(Self->;$start;$end)
      If (($end-$start)>0)
         ENABLE MENU ITEM($menuRef_t;1)  // Cut
         ENABLE MENU ITEM($menuRef_t;2)  // Copy
      Else 
         DISABLE MENU ITEM($menuRef_t;1)  // Cut
         DISABLE MENU ITEM($menuRef_t;2)  // Copy
      End if 

        // determine enabled/disabled for Paste item
      If (Get text from pasteboard="")
         DISABLE MENU ITEM($menuRef_t;3)  // Paste
      Else 
         ENABLE MENU ITEM($menuRef_t;3)  // Paste
      End if 

        // display the menu
      $menuItem_t:=Dynamic pop up menu($menuRef_t)

        // handle the selected item
      Case of 
         : ($menuItem_t="")
              // nothing selected

         : ($methodName_t#"")  // use custom method handler
            EXECUTE METHOD($methodName_t;*;$menuItem_t)

         : ($menuItem_t="Cut")  // handle default Cut operation
            POST KEY(Character code("x");Command key mask)

         : ($menuItem_t="Copy")  // handle default Copy operation
            POST KEY(Character code("c");Command key mask)

         : ($menuItem_t="Paste")  // handle default Paste operation
            POST KEY(Character code("v");Command key mask)

      End case 
   End if 
End if 


Tim

********************************************
Tim Nevels
Innovative Solutions
785-749-3444
[email protected]
********************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to