right-clicking on the TMenuItem

right-clicking on the TMenuItem

Postby Natter » Thu Nov 21, 2024 12:31 pm

Is it possible to handle right-clicking on the TMenuItem object ?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: right-clicking on the TMenuItem

Postby karinha » Thu Nov 21, 2024 1:21 pm

Maybe:

Code: Select all  Expand view  RUN

   SwapMouseButton( 1 ) // For Left-handers
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: right-clicking on the TMenuItem

Postby Natter » Thu Nov 21, 2024 1:44 pm

I didn't understand. How can I use SwapMouseButton(1 ) ? Any click (both right and left) on the TMenuItem object causes the selection of a menu option. I need to make this choice only on the left click. And use the right click for other purposes.
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: right-clicking on the TMenuItem

Postby karinha » Thu Nov 21, 2024 2:34 pm

Sorry Natter, it was the only idea that occurred to me at the time. Comment what you would do differently, PLS.

Code: Select all  Expand view  RUN

// C:\FWH\SAMPLES\NATTER3.PRG

#include "Fivewin.ch"

STATIC cName1

FUNCTION Main()

   LOCAL oWnd

   cName1 := "Test"

   DEFINE WINDOW oWnd

   oWnd:bRClicked  := {| nRow, nCol, nFlags | MyMenu( oWnd, nRow, nCol ) }

   ACTIVATE WINDOW oWnd CENTERED

RETURN NIL

FUNCTION MyMenu( oWnd, nRow, nCol )

   LOCAL oMenu, oItem1, oItem2, oItem3
   LOCAL cName := "Test.."
   LOCAL cName2 := "Test2"

   MENU oMenu POPUP 2007

//    IF lOptionLeft

      SwapMouseButton( 1 ) // For Left-handers

//    ENDIF

      MENUITEM oItem1 PROMPT "Natter Click" ;
          ACTION( oWnd:End() )

      MENUITEM oItem2 PROMPT cName1

      SEPARATOR

      MENUITEM oITem3 PROMPT "Others" ACTION MsgInfo( Len( oMenu:aMenuItems ) )

   ENDMENU

   ACTIVATE POPUP oMenu WINDOW oWnd  AT 140, 10

   SwapMouseButton( 0 )

RETURN( oMenu )

DLL32 FUNCTION SwapMouseButton(swap AS 7) AS 7 PASCAL LIB "USER32.DLL"

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: right-clicking on the TMenuItem

Postby cnavarro » Fri Nov 22, 2024 11:00 am

Natter wrote:Is it possible to handle right-clicking on the TMenuItem object ?


Hello
I implemented this in the menus a long time ago to account for this event, but I never got around to putting it into production.
I'll review my notes and let you know.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: right-clicking on the TMenuItem

Postby Natter » Fri Nov 22, 2024 11:36 am

Thanks, I'll be waiting !
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: right-clicking on the TMenuItem

Postby cnavarro » Fri Nov 22, 2024 1:00 pm

Natter wrote:Thanks, I'll be waiting !

Yes, I've already remembered it and it is indeed included in the Fivewin build
Simply:
Code: Select all  Expand view  RUN

oWnd:bRButtonMenuUp := { | nOrdItem, hMnu, nRow, nCol, o | MsgInfo( "Hello" ) }
 

These are the parameters you can receive in the codeblock
Code: Select all  Expand view  RUN

   Eval( ::bRButtonMenuUp, nOrdIt, hMnu, aPoint[ 1 ], aPoint[ 2 ], Self )
 

Try and comment
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: right-clicking on the TMenuItem

Postby Natter » Fri Nov 22, 2024 3:09 pm

Great !
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: right-clicking on the TMenuItem

Postby Natter » Tue Nov 26, 2024 10:41 am

For example, such a menu:

Code: Select all  Expand view  RUN
MENU oMen POPUP
   MENUITEM oItm PROMPT "Tree"
      MENU
          MENUITEM oItm PROMPT "First"
          MENUITEM oItm PROMPT "Second"
      ENDMENU
ENDMENU


Cristobal, I need to handle right-clicking on the "First" or "Second" menu options. I don't understand how to use :bRButtonMenuUp it in this case. :(
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: right-clicking on the TMenuItem

Postby karinha » Tue Nov 26, 2024 3:32 pm

Code: Select all  Expand view  RUN

// C:\FWH\SAMPLES\TUTOR09.PRG
// First works with browses

#include "FiveWin.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oBar

   SET _3DLOOK ON

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "Using a FiveWin quick browse" ;
      MENU( SwapMouseButton( 1 ), BuildMenu() )

   DEFINE BUTTONBAR oBar _3D SIZE 26, 27 OF oWnd 2007

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\printer.bmp" FLAT ;
      ACTION( SwapMouseButton( 0 ) )

   DEFINE BUTTON OF oBar FILENAME "..\bitmaps\16x16\Exit.bmp" FLAT ;
      ACTION( SwapMouseButton( 0 ), oWnd:End() ) TOOLTIP "Exit this app" GROUP

   SET MESSAGE OF oWnd ;
      TO "FiveWin - The xBase revolution" CENTERED ;
      CLOCK DATE KEYBOARD 2007

   ACTIVATE WINDOW oWnd MAXIMIZED

RETURN NIL

FUNCTION BuildMenu()

   LOCAL oMenu

   MENU oMenu 2007
      MENUITEM "&Information"
      MENU
         MENUITEM   "&About..." ;
            ACTION  MsgAbout( "FiveWin Tutorial", FWCOPYRIGHT ) ;
            MESSAGE "Information about this program"

         SEPARATOR

         MENUITEM   "&End..."  ;
            ACTION  If( MsgYesNo( "Want to end ?" ), oWnd:End(),) ;
            MESSAGE "End this application"
      ENDMENU

      MENUITEM "&Files"
      MENU
         MENUITEM   "&Customers..." ;
            ACTION  Customers() ;
            MESSAGE "Customers maintainance"

         MENUITEM   "&Stock" ;
            ACTION  MsgInfo( "Your Stock control goes here" ) ;
            MESSAGE "Stock control"
      ENDMENU

      MENUITEM "&Utils"
      MENU
         MENUITEM   "&Calculator..." ;
            ACTION  WinExec( "Calc" ) ;
            MESSAGE "Run Windows calculator"

         MENUITEM   "C&alendar..." ;
            ACTION  WinExec( "Calendar" ) ;
            MESSAGE "Run Windows calendar"

         MENUITEM   "&Have some fun..." ;
            ACTION  WinExec( "Sol" ) ;
            MESSAGE "Play a game..."
      ENDMENU
   ENDMENU

RETURN( oMenu )

FUNCTION Customers()

   IF .NOT. File( "clientes.dbf" )
      dbCreate( "Clientes.dbf", { { "Nombre",    "C", 40, 0 }, ;
                                  { "Direccion", "C", 50, 0 }, ;
                                  { "Telefono",  "C", 12, 0 }, ;
                                  { "Edad",      "N",  2, 0 }, ;
                                  { "Productos", "C", 10, 0 }, ;
                                  { "Nivel",     "N",  2, 0 } } )
   ENDIF

   USE Clientes

   IF RecCount() == 0
      APPEND BLANK
   ENDIF

   INDEX ON Clientes->Nombre TO CliNombr
   SET INDEX TO CliNombr
   GO TOP

   Browse( "Customers Control", "Cutomers info" )

   MsgInfo( "After browse" )

   USE

RETURN NIL

DLL32 FUNCTION SwapMouseButton(swap AS 7) AS 7 PASCAL LIB "USER32.DLL"

// FIN / END
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 44 guests