:onclick on bitmap not working

Moderator: Rathinagiri

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

:onclick on bitmap not working

Post by Ricci » Sun Oct 09, 2011 2:22 pm

If I try to assign a :onClick( { || .... } ) to a bitmap object, I get a QLABEL:CONNECT(0) error.

BITMAP inherits this method from LABEL and BASIC (over CONTROL). But which of them is chosen?

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: :onclick on bitmap not working

Post by l3whmg » Mon Oct 10, 2011 12:47 pm

Hi Ricci.
You are right: BITMAP inherits from LABEL....but (and I'm not a guru):
1) LABEL must be aligned about event handling, but this, probably, it's not the most important problem.
2) within LABEL, you can see there is an overwrite about OnClick method and a ProcessMouseKey. Why this? Because, QLabel (QT real object) doesn't has the same signal as button: we must catch "when a mouse button is pressed....."

For this reasons (I think) the onclick upon bitmap can't work properly.

This is my little opinion: I will investigate much more.
Luigi from Italy
www.L3W.it

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: :onclick on bitmap not working

Post by mrduck » Mon Oct 10, 2011 1:01 pm

Ricci wrote:If I try to assign a :onClick( { || .... } ) to a bitmap object, I get a QLABEL:CONNECT(0) error.

BITMAP inherits this method from LABEL and BASIC (over CONTROL). But which of them is chosen?

This line

Code: Select all

CLASS BITMAP FROM CONTROL, LABEL
is wrong....

Should be

Code: Select all

CLASS BITMAP FROM LABEL
since Label derives from Control...


As Luigi said, QLabel overrides method onClick since it doesn't have the clicked() signal.... and probably the double (circular) inheritance let the class use the basic:onClick method...

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Re: :onclick on bitmap not working

Post by Ricci » Mon Oct 10, 2011 2:11 pm

mrduck wrote: Should be

Code: Select all

CLASS BITMAP FROM LABEL
since Label derives from Control...
Well done, Francesco. This solve the problem, now it´s working.

Thanks ... Ricci

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Re: :onclick on bitmap not working

Post by Ricci » Mon Oct 10, 2011 2:16 pm

Btw. can anyone put this extension of onclick in IMAGE to hmg.ch into SVN please:

Code: Select all

/*----------------------------------------------------------------------*/
//                                Image
/*----------------------------------------------------------------------*/

#xcommand DEFINE IMAGE <tagreference> ;
      [ <dummy1: OF, PARENT> <oParent>       ] ;
      [ TOVAR <varname>                      ] ;
      [ AT                   <nRow> , <nCol> ] ;
      [ ROW                  <nRow>          ] ;
      [ COL                  <nCol>          ] ;
      WIDTH                  <nWidth>          ;
      HEIGHT                 <nHeight>         ;
      PICTURE                <cPicture>        ;
      [ BACKCOLOR            <aBackColor>    ] ;
      [ TOOLTIP              <cToolTipText>  ] ;
      [ <lTabStop          : TABSTOP>        ] ;
      [ <lStretch          : STRETCH>        ] ;
      [ <lScaledToHeight   : SCALEDTOHEIGHT> ] ;
      [ <lScaledToWidth    : SCALEDTOWIDTH>  ] ;
      [ <dummy2: ACTION,ON CLICK,ONCLICK> <bOnClick> ];
   =>;
   With Object [<varname> :=] BITMAP():New(<"tagreference"> [ , <oParent> ]) ;;
      [:Row            := <nRow>              ]   ;;
      [:Col            := <nCol>              ]   ;;
      [:Width          := <nWidth>            ]   ;;
      [:Height         := <nHeight>           ]   ;;
      [:Picture        := <cPicture>          ]   ;;
      [:BackColor      := <aBackColor>        ]   ;;
      [:ToolTip        := <cToolTipText>      ]   ;;
      [:TabStop        := <.lTabStop.>        ]   ;;
      [:Stretch        := <.lStretch.>        ]   ;;
      [:ScaledToHeight := <.lScaledToHeight.> ]   ;;
      [:ScaledToWidth  := <.lScaledToWidth.>  ]   ;;
      [:OnClick   := <{bOnClick}>      ]                 ;;
   End With

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: :onclick on bitmap not working

Post by l3whmg » Mon Oct 10, 2011 5:17 pm

Hi Ricci,
could you please give me a little example of your code?
Because I coded this

Code: Select all

DEFINE IMAGE image1
ROW 10
COL 10
ONCLICK MsgInfo("This")
WIDTH 100
HIGHT 100
END IMAGE
and work fine.

IMHO, about your referred command it seem "not very good". If you take a look, there is another "define image" command.
Anyway, please give me your example.
Thanks
Luigi from Italy
www.L3W.it

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Re: :onclick on bitmap not working

Post by Ricci » Mon Oct 10, 2011 6:25 pm

l3whmg wrote: IMHO, about your referred command it seem "not very good". If you take a look, there is another "define image" command.
Anyway, please give me your example.
Thanks
Sorry, I mean "extend the current definition" of "define image" in HMG.CH, only add the 2 new lines.

Code: Select all

DEFINE IMAGE lichtF AT 379,015 WIDTH 35 HEIGHT 25 PICTURE ":lichtu" ONCLICK { || ... }

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: :onclick on bitmap not working

Post by l3whmg » Mon Oct 10, 2011 6:58 pm

Hi Ricci.
I'm very, very :oops: but I don't understand what you want or mean.
What lines?

This code doesn't work

Code: Select all

DEFINE IMAGE lichtF
   ROW 379
   COL 015
   WIDTH 35 
   HEIGHT 25 
   PICTURE ":lichtu"
   ONCLICK { || ... }
END IMAGE

AnyWay, please, try this or tell me if your source is an HMG3 source coded.
Luigi from Italy
www.L3W.it

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: :onclick on bitmap not working

Post by l3whmg » Mon Oct 10, 2011 7:13 pm

Hi Ricci.
Ok I understand what do you mean. But please, tell me this: do you have a HMG3 program? Or do you are coding a new program with XBase style?

Cheers
Luigi from Italy
www.L3W.it

User avatar
l3whmg
Posts: 694
Joined: Mon Feb 23, 2009 8:46 pm
Location: Italy
Contact:

Re: :onclick on bitmap not working

Post by l3whmg » Mon Oct 10, 2011 7:21 pm

I'm asking to you because if you are coding a new program, you must prefer this syntax

Code: Select all

DEFINE IMAGE ImageName
ParameterName1 Value
ParameterName2 Value
ParameterNameN Value
END IMAGE
Cheers
Luigi from Italy
www.L3W.it

Post Reply