Custom button control

hello,

i want to define a custom behaviour for the button control

the goal is to have a button that has a particular image on hover, when it is pushed, and when it is released
i also want to be able to define a toggle state wich allows the button to remain down (among a group of buttons)

a bit like windows/X interface buttons

so as i checked the ButtonControl class, i see that it is deprecated and suggested to use de.lessvoid.nifty.controls.Button
but i can’t find any class that implements that interface

do i have to use this, or can i just rewrite/override the ButtonControl class ?
what is the best practice here ?

thx

Use a builder to construct new buttons (if you want to do it from code) or add it as usual in the xml.

To change the style for all buttons take nifty style black (or any other premade style) and modify it for your buttons.

To change it for one button you will either have to create your own version of button or get fancy with over-riding the style. I’m not sure off hand how to do that but I think it is possible.

The ButtonControl class is the correct class, it was deprecated to get people to switch to accessing the interface as the interface was added later. It is actually the class in use and live though.

<cite>@zarch said:</cite> The ButtonControl class is the correct class, it was deprecated to get people to switch to accessing the interface as the interface was added later. It is actually the class in use and live though.

thx for your answers
but the basic implementation of the nifty button is really weird

  • the button styles seems to use onfocus to change the image with imageChange effect
    so the buttons gets focused as i click on it …
    and then it keeps focused, then it does not remove the imageChange

wich leads to a really ackward behaviour, : as the button gets clicked, it changes color(image) and remains that way…

  • the controller seems to call the onclick when it receives the Activate event
    and when it receives mouse buttons event, it only seems to change the focus status

wich makes me wonder about the meaning of Activate and Focus status/events (??)

is it alright if i use the mouse clicks to change the images and call onclick when the mouse button is released ?
i mean why is it not implemented that way ?

as i use imageMode="sprite-resize… how do i change the sprite id of the current backgroundImage when i hover/click the button ?

thx

Honestly, I don’t use the nifty buttons. I just use a standard panel with a few effects to change the image appropriately.

<cite>@zarch said:</cite> Honestly, I don't use the nifty buttons. I just use a standard panel with a few effects to change the image appropriately.

yep, sounds simpler

thx anyway