Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
_gb3.pngLABEL - Use label as button
Use LAST comand and groups




Today for our example, we will use last, groups, enter and leave commands.
We will create one application with 6 labels. When i enter in one label, background color will change in black, and when i leave this label, color return to origin as photo bellow.

A) Event ENTER (Mouse go inside label)


When mouse will go inside label, we will use ENTER method. We will put code in this place.

B) Event LEAVE (Mouse quit surface label)

LWhen mouse will go out this label ,  LEAVE method will be used.We will put code in this place too.

C) Command LAST.

This command is very usefull. You can create group of widgets, who will react to the same event.
You can return data as :

Last.Tag = return TAG property of last widget
Last.Text = return TEXT property of last widget
Last.Background =  return BACKGROUND, property of last widget, etc...

We understand now :

In ENTER, method, let write this code :

Last.background = Color.Black

In LEAVE, method, let write this code :

Last.background = CInt(Last.tag)

why last.tag ?
J'Because i have written inside TAB property code of background original color.

For example DARKGREEN has this value integer : 32768.

How i know which color code? Simple! write in source code page this code : color. as picture bellow :



and you will see code corresponding.

Cint convert INTEGER from string written in TAG.

D) group notion


In conclusion, group notion in gambas is very important, you can join somme widgets together.
  In GROUP property of every label , let write one name (here bb )
Only one event will be created, that's great to have light code.

E) Return what label who is clicked.

To know exactly what label is clicked, use last command.
We will show in messagebox for our example like this :


Message.Info(Last.Text & "," & Last.tag)

Note than label widget doesn't have click event. We will use mousedown event.

  Here code of this application:

Public Sub bb_Enter()
Last.background = Color.Black
End

Public Sub bb_Leave()
Last.background = CInt(Last.tag)
End

Public Sub Form_Open()
Me.Center()
End

Public Sub bquit_Click()
Me.Close()
End

Public Sub bb_MouseDown()
Message.Info(Last.Text & "," & Last.tag)
End


  Thanks for your attention.


Creation date : 13/03/2022 @ 19:49
Last update : 13/03/2022 @ 20:38
Category : LABEL
Page read 1206 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^