Page 1 of 1

HMG.4 and "Onclick"

Posted: Fri Nov 11, 2011 1:10 am
by Rossine
Hello All,

I'm trying to make a shortcut to a button, but the error is occurring in execution.

See the example below:

Code: Select all

/*
 * $Id: demo_2.prg 760 2011-10-21 12:01:51Z l3wonsf $
*/

/*
 * HMG 4 demo
 * (c) 2010 Roberto Lopez <mail.box.hmg@gmail.com>
*/

#include "hmg.ch"

FUNCTION Main

   LOCAL oWindow

   hbqt_errorsys()

   DEFINE MAINWINDOW oWindow
      Row    10
      Col    10
      Width  400
      Height 400
      Title  'Nice OOP Demo!!!'
      OnInit oWindow:Center()

     ON KEY ALT+A OF cWndForm ACTION cWndForm.oButton1.OnClick  // <- Here

      DEFINE TOOLBAR oToolBar1

         TOOLBUTTON oButton1 ;
            Caption 'new' ;
            picture 'new.png' ;
            ACTION MsgInfo( 'New!' ) ;
            tooltip 'tooltip'

         TOOLBUTTON oButton2 ;
            Caption 'open' ;
            picture 'open.png' ;
            ACTION MsgInfo( 'open!' ) ;
            tooltip 'tooltip'

      END TOOLBAR

   END WINDOW

   ACTIVATE WINDOW oWindow

   RETURN NIL
This is possible in hmg.4 ?

Best Regards,

Rossine.

Re: HMG.4 and "Onclick"

Posted: Fri Nov 11, 2011 7:19 am
by Ricci
Please try this:

ON KEY ALT+A OF oWindow ACTION EVAL( oWindow:oToolBar1:oButton1:OnClick() )

And put the line behind the toolbar defnition block.

Re: HMG.4 and "Onclick"

Posted: Fri Nov 11, 2011 10:20 am
by Rossine
Hi Ricci,
Ricci wrote:Please try this:

ON KEY ALT+A OF oWindow ACTION EVAL( oWindow:oToolBar1:oButton1:OnClick() )

And put the line behind the toolbar defnition block.
Works 100% :D

Many thankĀ“s,

Rossine.