Slider: missing 'release' notification when clicking

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
mrupp
Posts: 147
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Slider: missing 'release' notification when clicking

Post by mrupp »

For my Sonos controller, I'm having a slider for the current song position. Dragging the slider should NOT yet jump to the position, but only change the text in a text class that shows the time. Only when releasing the slider I'd like to do the actual jump. So far, so good, I can perfectly handle this scenario using notify="level; release" on my slider.

BUT: clicking in the area left or right of the thumb in the slider will only trigger a "level" notification, but not a "release" notification, and therefore the jump will never be triggered in my code. The same goes when holding the mousebutton left or right from the thumb, which will do several steps, trigger a "level" notification for each one of them but never a "release" notification.

Imho, the solution would be to send a "release" notification when releasing the mouse button after clicking or holding it on the slider but not on its thumb.
I tested out this on Windows, btw.

Some more questions:
  1. Is there a way to set the step? On Windows, clicking left or right from the thumb always does a step of 10, on MUI (OS4) the step is 1.
  2. Double clicking the thumb on OS4 sets the slider to 0. Is that intended behaviour or a bug?
Here's an example script (partly take from Andreas' Demo.hws) to test this out:
Test.hws:

Code: Select all

@REQUIRE "RapaGUI", {Link = True}
@APPTITLE "Slider-Test"
@FILE 1, "TestGUI.xml"

Function p_Log(t$)
	moai.DoMethod("log", "insert", "bottom", GetTime(True) .. ": " .. t$)
	moai.DoMethod("log", "jump", "bottom")
EndFunction

Function p_EventFunc(msg)
	Switch(msg.ID)
	Case "slsetval":
		moai.Set("slider", "level", moai.Get("slsetvalnum", "text"))		
	Case "slsetrange":
		moai.Set("slider", "max", moai.Get("slsetrangenum", "text"))	
	Case "slider":
		Switch(msg.Attribute)
		Case "Level":
			moai.Set("sllevel", "text", msg.triggervalue)	
			p_Log("slider level: " .. msg.triggervalue)	
		Case "Release":
			p_Log("slider released")	
		EndSwitch
	EndSwitch
EndFunction

moai.CreateApp(ReadString(1))
InstallEventHandler({RapaGUI = p_EventFunc})

Repeat
	 WaitEvent
Forever
TestGUI.xml:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<application id="app">
	<window id="mainWindow" title="Slider-Test">
		<vgroup>
			<hgroup>
				<vgroup frame="true" frametitle="Slider demo">
					<colgroup columns="2">
						<label align="center">Current value</label>
						<text id="sllevel" frame="true">0</text>
						<button id="slsetval">Set value</button>
						<textentry id="slsetvalnum" accept="0123456789">0</textentry>	
						<button id="slsetrange">Set range</button>
						<textentry id="slsetrangenum" accept="0123456789">100</textentry>
					</colgroup>								
					<rectangle/>																							
				</vgroup>
				<slider id="slider" notify="level; release"/>																																																			
			</hgroup>	
			<listview id="log">
				<column/>
			</listview>	
		</vgroup>				
	</window>
</application>
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slider: missing 'release' notification when clicking

Post by airsoftsoftwair »

mrupp wrote: Mon Mar 01, 2021 2:29 pm Imho, the solution would be to send a "release" notification when releasing the mouse button after clicking or holding it on the slider but not on its thumb.
I tested out this on Windows, btw.
Right, this will be fixed.
mrupp wrote: Mon Mar 01, 2021 2:29 pm Some more questions:
[*]Is there a way to set the step? On Windows, clicking left or right from the thumb always does a step of 10, on MUI (OS4) the step is 1.
Right, this should be fixed as well.
mrupp wrote: Mon Mar 01, 2021 2:29 pm [*]Double clicking the thumb on OS4 sets the slider to 0. Is that intended behaviour or a bug?
No idea, ask tboeckel :)
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Slider: missing 'release' notification when clicking

Post by airsoftsoftwair »

Code: Select all

- New [Windows/macOS/Linux]: Added Slider.StepSize [ISG] attribute; this can be used to set the step size
  to use when clicking outside the thumb
- New: Added Slider.Drag [I] notification; this will trigger whenever the user starts to drag a slider's
  thumb; this is the counterpart to the Slider.Release [I] notification 
Post Reply