right-click Menu for Control

Post Reply
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

right-click Menu for Control

Post by Jimmy »

hi,

when create a CLASS from TControl() i want to add a "right-click Menu"

i do found

Code: Select all | Expand

METHOD LButtonDown()
METHOD LButtonUp()
but nothing for Right Button of Mouse :(

---

do i have to add

Code: Select all | Expand

METHOD HandleEvent()
   ...
   CASE nMsg == WM_RBUTTONDOWN
   CASE nMsg == WM_RBUTTONUP
and build own Method or does Fivewin have a other Way :?:
greeting,
Jimmy
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: right-click Menu for Control

Post by cnavarro »

Use for this DATA bRClicked
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
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: right-click Menu for Control

Post by nageswaragunupudi »

but nothing for Right Button of Mouse
TControl is derived from TWindow.
You need to search both TControl and TWindow classes.

You can see from TWindow class

Code: Select all | Expand

METHOD RButtonDown( nRow, nCol, nKeyFlags ) CLASS TWindow

   if ::bRClicked != nil
      Eval( ::bRClicked, nRow, nCol, nKeyFlags, Self )
   endif

return nil

//----------------------------------------------------------------------------//

METHOD RButtonUp( nRow, nCol, nKeyFlags ) CLASS TWindow

   if ::bRButtonUp != nil
      Eval( ::bRButtonUp, nRow, nCol, nKeyFlags, Self )
   endif

return nil

//----------------------------------------------------------------------------//
 
That means, you need to add method

Code: Select all | Expand

METHOD RButtonDown( nRow, nCol, nKeyFlags ) CLASS YourClass
Regards

G. N. Rao.
Hyderabad, India
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: right-click Menu for Control

Post by Jimmy »

hi,

thx for Answer.

i´m not sure that i understand what you say

i do have use

Code: Select all | Expand

METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS TGrid   

   DO CASE
      //  use for LVS_OWNERDRAWFIXED
      CASE nMsg == WM_MEASUREITEM
      CASE nMsg == WM_DRAWITEM
      // add for Context Menu
      CASE nMsg == WM_RBUTTONDOWN
         IF ::bRbClick != nil
            EVAL( ::bRbClick, ::oWnd, Self )
         ENDIF
      CASE nMsg == WM_RBUTTONUP
   ENDCASE

RETURN ::Super:HandleEvent( nMsg, nWParam, nLParam )
now you say i "just" need to "override"

Code: Select all | Expand

METHOD RButtonDown  ( nRow, nCol, nKeyFlags   )   CLASS YourClass
so i need not to handle WM_RBUTTONDOWN :?:
greeting,
Jimmy
User avatar
nageswaragunupudi
Posts: 10729
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: right-click Menu for Control

Post by nageswaragunupudi »

now you say i "just" need to "override"
Code:
METHOD RButtonDown ( nRow, nCol, nKeyFlags ) CLASS YourClass

so i need not to handle WM_RBUTTONDOWN :?:
Yes.

Wherever the parents have standard methods, you override them in your class and if needed return calling Super method.
Use HandleEvent very sparingly when there is no otherway.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: right-click Menu for Control

Post by Jimmy »

hi,
nageswaragunupudi wrote:Yes.
GREAT :D
nageswaragunupudi wrote:Use HandleEvent very sparingly when there is no otherway.
Ok, understood
greeting,
Jimmy
Post Reply