How to mark clicked button?

Questions, tips and tricks and techniques for scripting in Servoy

How to mark clicked button?

Postby alexander.sternadel » Fri Nov 22, 2024 1:44 pm

Hello everyone,

I'm just getting started with servoy and have a first draft of my application running :D
I have form with 8 buttons to load various sub-forms into a formcontainer.
Now I wan't to keep the highlight or mark the last clicked button, so that the user knows which sub-form he loaded, but can't find a command to write into the onAction(event) that loads the sub-from.
Do you have any ideas?

Cheers
Alexander
alexander.sternadel
 
Posts: 14
Joined: Fri Nov 22, 2024 1:33 pm

Re: How to mark clicked button?

Postby mboegem » Fri Nov 22, 2024 4:08 pm

Hi Alexander,

If you want to change the styling of a button you can do this by adding a style class to the element.
First of all you will need to create a css file (if you haven't done this yet) and add a class for the highlighting, for example
Code: Select all
.highlight {
   background-color: green;
}


Then in the onAction function you can add something like this:
Code: Select all
   elements.myButton.addStyleClass('highlight')


Similar to 'addStyleClass' there's also a removeStyleClass function to remove the class from an element.

Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1808
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to mark clicked button?

Postby alexander.sternadel » Mon Nov 25, 2024 1:41 pm

Thanks.

Works pertfect!
alexander.sternadel
 
Posts: 14
Joined: Fri Nov 22, 2024 1:33 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 5 guests