FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Ribbon Button's popup menu
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Ribbon Button's popup menu
Posted: Sat May 01, 2010 07:51 AM
Dear All,



How to determine if the popup menu of button was pressed or clicked by mouse?

I would like to alter instead of menu popup.. say xbrowse( 'table' )..

Can somebody point me the way..


Regards,
Frances
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 10:20 AM

If I understood correctly, you can use the ACTION clause.

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 11:33 AM
How to determine if the popup menu of button was pressed or clicked by mouse?

This click is handled in METHOD LButtonUp() in TRBtn.Prg. Here is the relevant portion of the code:
Code (fw): Select all Collapse
         if lClick
            if ::oPopup != nil
               do case
                  case ::nTypeButton == TYPE_SPLITPOPUP
                     if nRow >= ::nPopupMargin .or. ! lAction
                        oWnd := ::oWnd
                        oWnd:NcMouseMove() // close the tooltip
                        oWnd:oPopup = ::oPopup
                        ::oPopup:Activate( ::nTop + ::nHeight() + ;
                                           If( GetClassName( GetParent( GetParent( ::hWnd ) ) ) != "TRPANEL",;
                                               oWnd:nHeight(), 0 ), ::nLeft, oWnd, .F. )
                        oWnd:oPopup = nil
                        ::Refresh()
                     else
                        ::click()
                     endif
                     
                  case ::nTypeButton == TYPE_POPUP 
                     if nCol >= ::nPopupMargin .or. !lAction
                        oWnd := ::oWnd
                        oWnd:NcMouseMove() // close the tooltip
                        oWnd:oPopup = ::oPopup
                        ::oPopup:Activate( ::nTop + ::nHeight() + ;
                                           If( GetClassName( GetParent( GetParent( ::hWnd ) ) ) != "TRPANEL",;
                                               If( ! oWnd:IsKindOf( "TRIBBONBAR" ), oWnd:nHeight(), 0 ), 0 ),;
                                               ::nLeft - If( ! oWnd:IsKindOf( "TRBGROUP" ), oWnd:nLeft, 0 ), oWnd, .F. )                        
                        oWnd:oPopup = nil
                        ::Refresh()
                     else
                        ::click()
                     endif

Do you like to tinker with the code of TRBtn.Prg?
Regards



G. N. Rao.

Hyderabad, India
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 02:22 PM
Enrico Maria Giordano wrote:If I understood correctly, you can use the ACTION clause.

EMG



Dear EMG,

ACTION Clause if you pressed the button but the TYPE_SPLITPOPUP (the portion with popup menu) that I need to determine or alter the behavior say
instead of poping the popupmenu, maybe like invoking xBrowse( 'table' ) or an xbrowse list of records.. and still retain the ACTION clause default behavior.


Regards,
Frances
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 811
Joined: Tue May 06, 2008 04:28 AM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 02:30 PM
nageswaragunupudi wrote:
How to determine if the popup menu of button was pressed or clicked by mouse?

This click is handled in METHOD LButtonUp() in TRBtn.Prg. Here is the relevant portion of the code:
Code (fw): Select all Collapse
         if lClick
            if ::oPopup != nil
               do case
                  case ::nTypeButton == TYPE_SPLITPOPUP
                     if nRow >= ::nPopupMargin .or. ! lAction
                        oWnd := ::oWnd
                        oWnd:NcMouseMove() // close the tooltip
                        oWnd:oPopup = ::oPopup
                        ::oPopup:Activate( ::nTop + ::nHeight() + ;
                                           If( GetClassName( GetParent( GetParent( ::hWnd ) ) ) != "TRPANEL",;
                                               oWnd:nHeight(), 0 ), ::nLeft, oWnd, .F. )
                        oWnd:oPopup = nil
                        ::Refresh()
                     else
                        ::click()
                     endif
                     
                  case ::nTypeButton == TYPE_POPUP 
                     if nCol >= ::nPopupMargin .or. !lAction
                        oWnd := ::oWnd
                        oWnd:NcMouseMove() // close the tooltip
                        oWnd:oPopup = ::oPopup
                        ::oPopup:Activate( ::nTop + ::nHeight() + ;
                                           If( GetClassName( GetParent( GetParent( ::hWnd ) ) ) != "TRPANEL",;
                                               If( ! oWnd:IsKindOf( "TRIBBONBAR" ), oWnd:nHeight(), 0 ), 0 ),;
                                               ::nLeft - If( ! oWnd:IsKindOf( "TRBGROUP" ), oWnd:nLeft, 0 ), oWnd, .F. )                        
                        oWnd:oPopup = nil
                        ::Refresh()
                     else
                        ::click()
                     endif

Do you like to tinker with the code of TRBtn.Prg?


Dear RAO,

I tried oRbtn:bLButtonUp := {|nRow, nCol| xBrowse( 'table' ) } .. this is executed if I pressed the button or the popupmenu portion.. if I can only assign and execute the popupmenu portion.. and still retain the ACTION clause's default behavior..

This 'can be' similar to oPopup:bWhen maybe or a codeblock somewhere before oPopup:Activate()?


Regards,
Frances
Kind Regards,

Frances



Fivewin for xHarbour v18.07

xHarbour v1.2.3.x

BCC 7.3 + PellesC8 ( Resource Compiler only)

ADS 10.1 / MariaDB

Crystal Reports 8.5/9.23 DE

xMate v1.15
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 02:36 PM

Mr Fraxzi

Its not impossible. And I prefer to do it without altering library code. I shall try when I get some free time. Meanwhile you can also try. You know where to start anyway

Regards



G. N. Rao.

Hyderabad, India
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Ribbon Button's popup menu
Posted: Sat May 01, 2010 02:39 PM
Mr Fraxzi


is neccesary modify TRBTN Class

isn't difficult

add new data

DATA bOnPopup

Change METHOD LButtonUp( nRow, nCol ) CLASS TRBtn
Code (fw): Select all Collapse
METHOD LButtonUp( nRow, nCol )  CLASS TRBtn

   local oWnd
   local lClick := IsOverWnd( ::hWnd, nRow, nCol )
   local lAction := !empty( ::bAction )


   if ::lDrag .or. ! Empty( ::oDragCursor )
      return Super:LButtonUp( nRow, nCol )
   endif
   if ::bLButtonUp != nil
      Eval( ::bLButtonUp, nRow, nCol)
   endif

   ::lBtnUp  = .t.

   if ! ::lWorking

      if ::lCaptured
         ::lCaptured = .f.
         ReleaseCapture()
         if ! ::lPressed
            if ::lBtnDown
               ::lPressed = .t.
               ::Refresh()
            endif
         else
            if ! ::lBtnDown
               ::lPressed = .f.
               ::Refresh()
            endif
         endif
         if lClick
            if ::oPopup != nil
               do case


                  case ::nTypeButton == TYPE_SPLITPOPUP
                     if nRow >= ::nPopupMargin .or. ! lAction
                        if ::bOnPopup != nil
                           Eval( ::bOnPopup, nRow, nCol, Self ) 
                        else
                           oWnd := ::oWnd
                           oWnd:NcMouseMove() // close the tooltip
                           oWnd:oPopup = ::oPopup
                           ::oPopup:Activate( ::nHeight, 0, Self, .F. )
                           oWnd:oPopup = nil
                           ::Refresh()
                        endif
                     else
                        ::click()
                     endif
                     
                  case ::nTypeButton == TYPE_POPUP 
                     if nCol >= ::nPopupMargin .or. !lAction
                        if ::bOnPopup != nil
                           Eval( ::bOnPopup, nRow, nCol, Self ) 
                        else
                           oWnd := ::oWnd
                           oWnd:NcMouseMove() // close the tooltip
                           oWnd:oPopup = ::oPopup
                           ::oPopup:Activate( ::nHeight, 0, Self, .F. )                        
                           oWnd:oPopup = nil
                           ::Refresh()
                        endif
                     else
                        ::click()
                     endif
 
                     
                  otherwise
                     ::Click()
               endcase
            else

               do case
                  case ::nTypeButton == TYPE_SPLITPOPUP
                     if nRow >= ::nPopupMargin .or. !lAction
                        if ::bOnPopup != nil
                           Eval( ::bOnPopup, nRow, nCol, Self ) 
                        else                     
                           MsgInfo( "Non defined popup menu", "Class TRBtn" )
                        endif
                     else
                        ::click()
                     endif
                  case ::nTypeButton == TYPE_POPUP
                     if nCol >= ::nPopupMargin .or. !lAction
                        if ::bOnPopup != nil
                           Eval( ::bOnPopup, nRow, nCol, Self ) 
                        else                     
                           MsgInfo( "Non defined popup menu", "Class TRBtn" )
                        endif
                     else
                        ::Click()
                     endif
                  otherwise
                     ::Click()
               endcase
            endif
         endif
      endif
   endif

return 0

Continue the discussion