Page 1 of 1

ONCLICK question

Posted: Mon Apr 09, 2018 7:29 am
by asharpham
Is it possible to have more than 1 "onclick" entry in a button? I want the button click to do 2 things.

Alan

Re: ONCLICK question

Posted: Mon Apr 09, 2018 9:39 am
by dragancesu
Depends on what you want
When ON CLICK you can call a command, function, or procedure

What do you wnt?

Re: ONCLICK question

Posted: Mon Apr 09, 2018 10:11 am
by bpd2000
Simple example may help you, you may define multiple action in this way

Code: Select all

/*
 * HMG - Harbour Win32 GUI library
 * Copyright 2002-2008 Roberto Lopez <mail.box.hmg@gmail.com>
 * http://www.hmgforum.com//
*/

#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 400 ;
      HEIGHT 400 ;
      MAIN;
      TITLE 'Button Test'

      @ 10,10 LABEL Label_1 AUTOSIZE VALUE 'Value before button press'
      @ 70,170 BUTTON Button_1 CAPTION	'Test_Buton' ;
        ACTION (Form_1.label_1.value := "Button 1st event", ;
                 MsGINFO("Button 2nd event"))

   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return nil

Re: ONCLICK question

Posted: Mon Apr 09, 2018 1:32 pm
by asharpham
Thanks for that. But I use "define button" and in the docs ACTION is not shown as an option. Anyway, I decided to try the same idea with "ON CLICK" and it seems to work: ONCLICK { DeleteCheck := .T. , SeekText() }.

Regards,
Alan

Re: ONCLICK question

Posted: Mon Apr 09, 2018 2:23 pm
by andyglezl
DEFINE BUTTON <ButtonName>
PARENT <ParentWindowName>
ROW <nValue>
COL <nValue>
CAPTION <cValue>
PICTURE <cValue>
PICTALIGNMENT Top | Left | Right | Bottom

ONCLICK <ActionProcedure>

WIDTH <nValue>
HEIGHT <nValue>
FONTNAME <cValue>
FONTSIZE <nValue>
FONTBOLD <lValue>
FONTITALIC <lValue>
FONTUNDERLINE <lValue>
FONTSTRIKEOUT <lValue>
TOOLTIP <cValue>
FLAT <lValue>
TRANSPARENT <lValue>
ONGOTFOCUS <ActionProcedure>
ONLOSTFOCUS <ActionProcedure>
TABSTOP <lValue>
HELPID <nValue>
VISIBLE <lValue>
MULTILINE <lValue>
END BUTTON



@ <nRow> ,<nCol>
BUTTON <ControlName>
[ OF | PARENT <ParentWindowName> ]
CAPTION <cCaption>
PICTURE <cPictureName> [ TOP | BOTTOM | LEFT | RIGHT ]

ACTION | ONCLICK | ON CLICK <ActionProcedureName> | <bBlock>

[ WIDTH <nWidth> HEIGHT <nHeight> ]
[ FONT <cFontName> SIZE <nFontSize> ]
[ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ]
[ TOOLTIP <cToolTipText> ]
[ FLAT ]
[ NOTRANSPARENT ]
[ ON GOTFOCUS <OnGotFocusProcedur> | <bBlock> ]
[ ON LOSTFOCUS <OnLostFocusProcedure> | <bBlock> ]
[ NOTABSTOP ]
[ HELPID <nHelpId> ]
[ INVISIBLE ]
[ MULTILINE ]


Is the same...