click callback on gauges

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

click callback on gauges

Post by Caled »

The following code creates a gauge and attempts to make it clickable.
It requires Vadi's 'CSSMAN' script, but aside from that it should run standalone.
Neither part of the gauge is clickable, with nothing printed to the main window, and nothing showing in the debug window to indicate that anything has happened at all.

Does anyone have any ideas?

I have a vague workaround idea if it is not possible to make gauges clickable, of putting each gauge inside a label the same size as the gauge, and then putting another label inside that label, transparent and hopefully on top of the gauge, then making that transparent label clickable. But that will mean I end up with a very convoluted parent>child structure (as the gauges will be in a hbox, which will be in a label, in turn in a container...

I understand gauges to be comprised of two labels, so it should be possible to make them clickable.

Code: Select all

GUI.GaugeBackCSS = CSSMan.new([[
  background-color: rgba(0,0,0,0);
  border-style: solid;
  border-color: white;
  border-width: 1px;
  border-radius: 5px;
  margin: 5px;
	qproperty-alignment: 'AlignCenter | AlignTop';
]])

GUI.GaugeFrontCSS = CSSMan.new([[
  background-color: rgba(0,0,0,0);
  border-style: solid;
  border-color: white;
  border-width: 1px;
  border-radius: 5px;
  margin: 5px;
	qproperty-alignment: 'AlignCenter | AlignBottom';
]])
-------------------------------
function gauge_pressed(sys)
	print(sys .. ' pressed')
end
-------------------------------
GaugeTest = Geyser.Gauge:new({
	name = "GaugeTest",
	x = 700, y=300,
	width = 80, height = 400,
	orientation='vertical',
})
GaugeTest.back:setStyleSheet(GUI.GaugeBackCSS:getCSS())
GUI.GaugeFrontCSS:set("background-color","red")
GaugeTest.front:setStyleSheet(GUI.GaugeFrontCSS:getCSS())
GaugeTest:setValue(math.random(100),100)
GaugeTest.back:echo("Gauge test")
-------------------------------
GaugeTest.front:setClickCallback('gauge_pressed', 'Gauge test')
GaugeTest.back:setClickCallback('gauge_pressed', 'Gauge test')

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: click callback on gauges

Post by Jor'Mox »

I’m not certain about gauges within Geyser, as it doesn’t use the gauges that Mudlet provides, but the standard Mudlet gauges actually use three labels, one for the back part of the gauge that you see, one for the front, and one for the text. This is because it used to be that the text was written on the front label, and when the gauge shrunk too much, the text became hard to read, and didn’t look very good. So, assuming Geyser does something similar, you actually need to target the label with the text on it, as it completely covers the other two.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: click callback on gauges

Post by demonnic »

Geyser does this as well, yes. In your example it would be GaugeTest.text

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: click callback on gauges

Post by Caled »

Thanks for the help guys. That also explains why text alignment via stylesheet wasn't working.

Post Reply