Cursor ON Ribbon

Post Reply
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Cursor ON Ribbon

Post by Silvio »

Can I use a Hand cursor on RibbonBar ? to have a compatibilidad with oBar?
Best Regards, Saludos

Falconi Silvio
User avatar
Armando
Posts: 3382
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Cursor ON Ribbon

Post by Armando »

Up

SOI, s.a. de c.v.
[email protected]
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Cursor ON Ribbon

Post by Antonio Linares »

Yes, you can use a Hand cursor on TRibbonBar, but it requires manual assignment since the DEFINE RIBBONBAR command does not have a built-in CURSOR clause like DEFINE BUTTONBAR does.

The difference

With TBar (ButtonBar): The CURSOR clause is part of the command syntax, and the cursor is automatically propagated to each button via TBtnBmp::NewBar(): 0-cite-0 0-cite-1

With TRibbonBar: The command in ribbon.ch has no CURSOR clause: 0-cite-2

How to do it

Since TRibbonBar and TRBtn both inherit from TControl -> TWindow, they all have the oCursor property. The TWindow::MouseMove method checks ::oCursor and calls SetCursor() automatically: 0-cite-3

And TRBtn::MouseMove delegates to Super:MouseMove which triggers the same cursor logic: 0-cite-4

So you can set it manually after creating the RibbonBar:

Code: Select all | Expand

LOCAL oCursor

DEFINE CURSOR oCursor HAND

DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Tab 01", "Tab 02" ;
      HEIGHT 130 TOPMARGIN 25

// Set cursor on the ribbon bar itself
oRBar:oCursor := oCursor

// Set cursor on all ribbon buttons inside each group/tab
LOCAL n, m, p, oGroup, oButton
FOR n = 1 TO Len( oRBar:aDialogs )
   IF oRBar:aDialogs[ n ]:aControls != NIL
      FOR m = 1 TO Len( oRBar:aDialogs[ n ]:aControls )
         oGroup := oRBar:aDialogs[ n ]:aControls[ m ]
         oGroup:oCursor := oCursor
         IF oGroup:aControls != NIL
            FOR p = 1 TO Len( oGroup:aControls )
               oGroup:aControls[ p ]:oCursor := oCursor
            NEXT
         ENDIF
      NEXT
   ENDIF
NEXT

This is the same pattern used in ButtonBar samples where cursors are applied via AEval: 0-cite-5 0-cite-6

The approach is functionally equivalent - it just requires iterating through the RibbonBar's dialog panels, groups, and buttons to set the cursor on each control individually, since TRibbonBar doesn't automatically propagate oCursor to child controls the way TBar does.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply