Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Button Colour should change when it is active i.e. when it is clicked

I have a button which selects a multiple values of a field when we clik on it. And another button which unselects the values when we click on it.

I want that the colour of the button should change when we clik on it.So that i can distinguish between the buttons that it is cliked and it is active.

5 Replies
Not applicable
Author

hi rahul,

probably the following code should work

sub activate

set mybutton=activedocument.getsheetobject("BU01")

set prop= mybutton.getproperties

prop.bkgcolor.primarycol.col=rgb(0,255,0)

mybutton.setproperties prop

end sub

sub deactivate

set mybutton=activedocument.getsheetobject("BU01")

set prop= mybutton.getproperties

prop.bkgcolor.primarycol.col=rgb(255,255,255)

mybutton.setproperties prop

end sub



thanks

Not applicable
Author

Thanks Tauqueer,

It has solved my purpose.It working as per my requirements.

Thanks a lot.

Regards,

Rahul

Not applicable
Author

hey... great solution.

This is great when you have one button,

what if i have a series of button? says 2?

then i want them to toggel between each other?

I was thinking of if else statement for the button, but i couldn't find the vb script to detect which button is clicked?

Any hints?

Not applicable
Author

Hi! Nic,

Well this can be done with 2 buttons you can write activate and deactivate script in two different buttons and then we can toggle between them.

Regards,

Rahul

Not applicable
Author

Hi Rahul,

Thanks for the suggestion, following is my code for 2 button, if i have 10 buttons in different tabs, i'd have 10 sets?

I'm trying to find the vbcode for...

>> if button 16 is click, get the active button 16 - BU16... how to translate to vbscript?

any idea?



sub activate
set mybutton=activedocument.getsheetobject("BU16")
set prop= mybutton.getproperties
prop.bkgcolor.primarycol.col=rgb(0,255,0)
mybutton.setproperties prop

set mybutton=activedocument.getsheetobject("BU17")
set prop= mybutton.getproperties
prop.bkgcolor.primarycol.col=rgb(0,51,170)
mybutton.setproperties prop

end sub


sub activate2

set mybutton=activedocument.getsheetobject("BU17")
set prop= mybutton.getproperties
prop.bkgcolor.primarycol.col=rgb(0,255,0)
mybutton.setproperties prop

set mybutton=activedocument.getsheetobject("BU16")
set prop= mybutton.getproperties
prop.bkgcolor.primarycol.col=rgb(0,51,170)
mybutton.setproperties prop

end sub