[Gambas-user] Re: Some Captured, Some Not

johnf jfabiani at ...1109...
Thu Jan 12 00:27:24 CET 2006


On Wednesday 11 January 2006 14:39, Benoit Minisini wrote:
> On Wednesday 11 January 2006 21:15, A Person wrote:
> > Good Day Benoit . . .
> >
> > The previous code was part of a much larger project and was not really a
> > stand alone module so I created a sample for your attention.
> >
> > I do not know what is happening but the code that I wrote here for you
> > doesn't work at all.
> >
> > Nothing triggers the Label KeyPress or Label KeyRelease events.
> > MouseDown works.
> >
> > Please try this code and tell me what I am doing wrong?
> >
> > I really appreciate it.
> >
> > . . .
> > ' Gambas class file
> >
> > PUBLIC SUB Form_Open()
> >
> >    ' requires a form with a label "Label1"
> >    ' with no text
> >    Label1.SetFocus
> >
> > END
> > PUBLIC SUB Label1_KeyPress()
> >
> >    ' F9 (breakpoint) the next line
> >    Label1.Caption = "Down " & Key.Code
> >    ' It is never tripped
> >
> > END
> > PUBLIC SUB Label1_KeyRelease()
> >
> >    ' F9 (breakpoint) the next line
> >    Label1.Caption = "Up " & Key.Code
> >    ' It is never tripped
> >
> > END
> > PUBLIC SUB Label1_MouseDown()
> >
> >    ' to test for focus
> >    Label1.Caption = "MouseDown"
> >
> > END
> > PUBLIC SUB Timer1_Timer()
> >
> >    'set to interval 10
> >    Label1.SetFocus
> >
> > END
> > . . .
> >
> > Thanks
> >
> > Paul
>
> A Label only displays things, and cannot get focus, and so I think it never
> raises keyboard events.
>
> Regards,

I think what you need to do is use a "TextLabel".  A textlabel will allow 
events such as the keypress.  In fact you can make it look just like a normal 
label with background, etc.....  I do something like what your doing 
(clicking on my textlabel causes a form to open) but I make my textlabel with 
a yellow background to make it stand out.
John




More information about the User mailing list