Custom nifty gui button

Hi everybody!

I was wondering if it was possible to use a custom button instead of the default button included with nifty gui ?


I think you could probably use an image as a button. Just add the image, put text overlaying it if you want, and add a callback.

No, buttons aren’t the same of images, if you wanna to create yourself buttons or the custom control, just create your control definition and a nifty control for that, after that you have to create yourself “nifty-controls.xml”, like “my-custom-controls.xml” which references your custom controls, and register that in your screens by doing [xml]<useControls filename=“Interface/my-custom-controls.xml” />

[/xml], then the image is inside the button’s background panel. You can do the same for the styles, you can create yourself styles and register them by doing [xml]<useStyles filename=“Interface/my-custom-styles.xml”/>[/xml]. Creating custom controls is like creating screens, you create a controller and a xml file. About custom styles creation, there’s a information about that in nifty gui scenarios tutorial. I learnt how to do those stuffs by looking at the nifty source code, you can check that here : then I saw how the internal stuffs are created, you can check how the default button is created internally. Good luck, and be patient ;)!

With regards to custom buttons…

There’s indeed two ways, a full custom control or just a custom style. Which is best for you depends on the end result you want to achieve. If all you want to achieve is a certain look and feel, the custom style is the way to go.