TRIBBON + ALT

Post Reply
MGA
Posts: 1289
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

TRIBBON + ALT

Post by MGA »

In the RibbonBar, I have 12 tabs; when I press Alt (accelerator), Tab 1 doesn't work, but Tab 11 does.

[email protected]

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
User avatar
karinha
Posts: 8720
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: TRIBBON + ALT

Post by karinha »

Mostre como você aciona a Guia 11, porfa.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
MGA
Posts: 1289
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: TRIBBON + ALT

Post by MGA »

João, when you press the ALT key, numbers 1 through 11 appear on the tabs. There is a glitch: if you press 11, it navigates to the corresponding tab, but if you press 1, it doesn't.

[email protected]

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
User avatar
Antonio Linares
Site Admin
Posts: 44515
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: TRIBBON + ALT

Post by Antonio Linares »

Fix: TRibbonBar tab keyboard accelerators with 10+ tabs (source\classes\tribbon.prg):
With more than 10 tabs, RunAction() only fired accelerators after two keystrokes
(logic meant for ribbon controls like A0, B1). A single key such as 1 for Tab 1
was treated as a prefix of 10/11/12 and never executed. Fixed: unified prefix/exact
matching in RunAction() and zero-padded tab hints (01-09) in PaintAccTabs() when
there are 10 or more tabs.

Code: Select all | Expand

METHOD RunAction( nKey ) CLASS TRibbonBar

   local nCurrent := 0
   local lPartial := .F.
   local nLenBuf

   if nKey > 95 .and. nKey < 106
      nKey -= 48
   endif

   DEFAULT ::cBufferAcc := ""

   If nKey > 0
      ::cBufferAcc += Chr( nKey )
      nLenBuf = Len( ::cBufferAcc )
      if nLenBuf == 1
         if AScan( ::aAcc, {| uItem | Left( uItem[ 2 ], 1 ) == ::cBufferAcc } ) == 0
            ::cBufferAcc = ""
            return nil
         endif
      endif

  nCurrent = AScan( ::aAcc, {| uItem | uItem[ 2 ] == ::cBufferAcc } )
  lPartial = AScan( ::aAcc, {| uItem | Len( uItem[ 2 ] ) > nLenBuf .and. ;
     Left( uItem[ 2 ], nLenBuf ) == ::cBufferAcc } ) > 0

  if nCurrent > 0 .and. ! lPartial
     Eval( ::aAcc[ nCurrent, 1 ] )
  elseif nCurrent == 0 .and. ! lPartial
     ::ResetAcc()
  endif
   else
      ::ResetAcc()
   endif

return nil

Code: Select all | Expand

METHOD PaintAccTabs( hDC ) CLASS TRibbonBar
   local nTab
   local nSizeBox := 20
   local nTop := ::nTopMargin - ::nHeightFld + ( nSizeBox / 2 )
   local nWidth, nLeft, cAccKey

   ::aAcc = {}
   ::cBufferAcc = ""
   DrawBitmap( hDC, ::hSaveScr, 0, 0 )

   for nTab = 1 to Len( ::aLeft )
      nWidth := ::aSizes[  nTab ]
      nLeft  = ( ( nWidth  ) / 2 + ::aLeft[ nTab ]  ) - ( nSizeBox / 2 )
      cAccKey := if( Len( ::aLeft ) >= 10, PadL( Str( nTab ), 2, "0" ), AllTrim( Str( nTab, 2 ) ) )
      RoundRect( hDC, nLeft, nTop, nLeft + nSizeBox, nTop + nSizeBox, 5, 5 )
      TextOut( hDC, nTop + 2, nLeft + 2, cAccKey )
      AAdd( ::aAcc, AddAction( nTab, Self, cAccKey ) )
   next

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
MGA
Posts: 1289
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: TRIBBON + ALT

Post by MGA »

Sr. Antonio:

Image

[email protected]

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
Post Reply