Mouse position in slider

Post

Posted
Rating:
#1 (In Topic #266)
Regular
bill-lancaster is in the usergroup ‘Regular’
 I have a slider(Slider1) and want to know the X position of the mouse, without a left or right click, when its inside the slider.
Have set Slider1 Tracking to true but the MouseMove event doesn't show anything.
Any advice would be welcome
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’
Do you just want a pixel value for the mouse when inside the slider control or some derived value that matches the slider value.

For the simple case you could run a timer to report the mouse position:-

Code (gambas)

  1. Public Sub Timer1_Timer()
  2.  
  3.   Me.text = Mouse.ScreenX
  4.  

…and then make corrections based upon the position of the control on the form.

Code (gambas)

  1. Public Sub Timer1_Timer()
  2.  
  3.   Me.text = Mouse.ScreenX - Me.Left - Slider1.Left
  4.   If Val(Me.Text) < 0 Then
  5.     Me.Text = 0
  6.   If Val(Me.Text) > Slider1.Width Then
  7.     Me.Text = Slider1.Width  
  8.  

However, I have a feeling I'm miles away from understanding the question.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
Have a look at the attached code, does that help? My friend Matt is thinking that there is a bug in 'tracking'.

<IMG src="http://www.cogier.com/gambas/mouse_position.png"> </IMG>

Attachment

UPDATE: - The tracking works differently from other controls. It does not track the mouse but the slider. The help file states "Indicates that the Slider emits Change events continuously when it is moved, not just the mouse button is released."
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
bill-lancaster is in the usergroup ‘Regular’
 Thanks stevedee, the slider is showing the progress of an audio file playback. I want to show the exact time value when the mouse is positioned in the slider.

Thank you cogier for the demo file, I'm having trouble extracting it.
$:tar -xzf Test2.tar.gz
returns:-
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

Where am I going wrong?
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Regular
Cedron is in the usergroup ‘Regular’

stevedee said


…and then make corrections based upon the position of the control on the form.



However, I have a feeling I'm miles away from understanding the question.

That's a clever solution, somewhat hackish, but should be effective.  I looked and couldn't find a better way in the Wiki.

However, I think you also want to check the Mouse.Y value so that the mouse is either on or near the slider.

Miles?  I think you nailed it.

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Yogi)
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
Hi Bill, try this one.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
bill-lancaster is in the usergroup ‘Regular’
Thank you so much Cogier - perfect!
Online now: No Back to the top
1 guest and 0 members have just viewed this.