Page 1 of 1

Buttons Help

Posted: Tue Jul 03, 2018 4:38 am
by Dyron
I've been moving over to mudlet from cmud so I'm trying to learn how to do things I normally would do.

I love the use of buttons to enable things. I use one to enable my basher, a drop down to enable affliction methods, etc etc.

Generally, on the basher button it'd do black with red when disabled and black with green if enabled.

Disabled would disable my Class(Group in Mudlet) so that the balance triggers would trigger my bash attack.
Enabled would enable my Class(Group in Mudlet) so that the balance triggers would now fire my bash attack on balance regen.

Basically, I want to be able to do the black with red or green font by positions and make it disable/enable the Bashing Group.

Secondary, I'd like to do a drop down button with multiple selections to pick what affliction method I am wanting to use.

Would anyone be able to steer me the right way for this? The buttons wiki was extremely weak and honestly looks like it belongs to an older version of mudlet.

Re: Buttons Help

Posted: Sun Jul 08, 2018 2:12 pm
by Jor'Mox
I don't know anyone who uses actual buttons in Mudlet these days. To do what you are talking about, most people use labels combined with the setLabelClickCallback and related functions. That includes the drop down menu-like buttons you want to have.

So basically, you want to use createLabel to make each of the GUI objects that will be your buttons. You may then want to use the setLabelStyleSheet function to give it the look that you want. Then you will want to use the echo function to write text to your label (the default color for the text is black, and text for labels is formatted like HTML). And then you will use setLabelClickCallback to designate a function that will be called when the button is clicked. That function can then maintain a simple boolean variable to track if the "button" is "on" or "off", and use that to determine what it should do when a click is detected, such as changing the text displayed on the button, enabling or disabling various triggers (with enableTrigger and disableTrigger), or showing or hiding other buttons (this is how the dropdown menu effect is created, by showing already created labels which are then hidden when they are no longer needed).

Re: Buttons Help

Posted: Tue Jul 10, 2018 12:04 am
by SlySven
The button/menu/toolbars aspect of Mudlet is not as good as it could be right now. They can realistically only be created from the Editor and not from lua scripting. To get the sort of visual effects you can do a lot with the Stylesheet - note how I have cause the "Info on/off" button to have a magenta outline when I "hover" on it and for it to have a red background when it is "on" - the order of multiple styling entries that affect the widgets (i.e. QPushButttons) involved *is* important. It is not visible from that screenshot because my screen capture program did not capture the mouse pointer but it is actually over that particular button at the time:
When you involve successive groups you should know that the top most "group" becomes a "toolbar" and then any "group" below that becomes a "menu" whereas the "items" within them are the "buttons". Only buttons have executable code - because clicking on a menu has to display the buttons/items that it contains. You can style the QPushButtons and the QToolBars (or is it QToolbars) fairly simply by following the details of Qt Stylesheet reference for the menus it is a bit more complicated!

Note that one of my buttons there contains an icon - there was code back in ancient versions of Mudlet that could put icons into the buttons and the core of the load and saving code preserves their inclusion in buttons but the ability to manipulate them got lost somewhere before 2.1 came out and though I have experimented with getting it back into the codebase I never finished it off so that that feature is currently not available.