I have a couple of sliders in my visu. Is it possible to get a signal from a slider that it is being touched?
I'm not thinking about the value that I change, but rather a BOOL that goes TRUE when I touch the slider and FALSE again when I don't touch it.
I have tried with hollow buttons, invisible buttons etc with no luck.
Paul
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
m.prestel hat geschrieben:
Hello Paul,
do you mind sharing what you want to do with this signal?
This may help me or others understand what you need and how you can achieve it.
Best regards,
Marcel
Hi Marcel.
I want the slider to go back to a set value when I release it. My slider spans from -100 to + 100. I want it to 0 when I don't touch it.
I thought I could write a small code that takes the slider to 0 when that signal goes FALSE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't know if this is the correct way of doing it but this has worked for me in the past. You can build off of this to make sure the pointer is valid, slider element is pointing to the correct slider, etc...:
VAR_INPUT
  siSlider1POS : SINT :=0; (*Slider value*)END_VARVAR
  xInit : BOOL :=TRUE;
  pSlider1 : POINTERTOvisufbelemslider; (*Library part of "System_VisuElemsWinControls that should already be in your project*)END_VARIFxInitTHEN
  xInit :=FALSE;
  pSlider1 :=ADR(__VisuInitInstantiation_Gvl.__VisuInitInstantiation_Instance.inst__Home.GEN_Instance_2._visufbelemslider[0]); (*Pointer to slider*)END_IFIFNOTpSlider1^.m_bDraggedTHEN
  siSlider1POS :=0; //Set slider value to 0 when slider is not being dragged.END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
attached you can find an example using the interface IMouseEventHandler.
With this you are not depending on internal structures, which may change at any time.
Keep in mind, this attached example is only designed for a single client!
If you have multiple clients, we would have to store the iSliderValueOnMouseDown in an array.
Comingback4u hat geschrieben:
Don't know if this is the correct way of doing it but this has worked for me in the past. You can build off of this to make sure the pointer is valid, slider element is pointing to the correct slider, etc...:
VAR_INPUT
  siSlider1POS : SINT :=0; (*Slider value*)END_VARVAR
  xInit : BOOL :=TRUE;
  pSlider1 : POINTERTOvisufbelemslider; (*Library part of "System_VisuElemsWinControls that should already be in your project*)END_VARIFxInitTHEN
  xInit :=FALSE;
  pSlider1 :=ADR(__VisuInitInstantiation_Gvl.__VisuInitInstantiation_Instance.inst__Home.GEN_Instance_2._visufbelemslider[0]); (*Pointer to slider*)END_IFIFNOTpSlider1^.m_bDraggedTHEN
  siSlider1POS :=0; //Set slider value to 0 when slider is not being dragged.END_IF
Hi, and thanks for reply.
I am having trouble pointing to my slider. It has ID 0 i my visu. Is it suppose to be located in the Input Assistant?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
If you can do it the way M.Prestel shows it i'm sure it is a better approach. If you can't do it that way maybe you could upload a sample project for me to take a look at. As Marcel mentions Pointers is not the best approach but I'm using 3.5.5.4 and don't know if his approach is available in this version. Haven't had time to look into it thoroughly. What version of CoDeSys are you using also helps.
Regards,
CB
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
I have a couple of sliders in my visu. Is it possible to get a signal from a slider that it is being touched?
I'm not thinking about the value that I change, but rather a BOOL that goes TRUE when I touch the slider and FALSE again when I don't touch it.
I have tried with hollow buttons, invisible buttons etc with no luck.
Paul
Hello Paul,
do you mind sharing what you want to do with this signal?
This may help me or others understand what you need and how you can achieve it.
Best regards,
Marcel
Hi Marcel.
I want the slider to go back to a set value when I release it. My slider spans from -100 to + 100. I want it to 0 when I don't touch it.
I thought I could write a small code that takes the slider to 0 when that signal goes FALSE.
Don't know if this is the correct way of doing it but this has worked for me in the past. You can build off of this to make sure the pointer is valid, slider element is pointing to the correct slider, etc...:
Hello Paul,
attached you can find an example using the interface IMouseEventHandler.
With this you are not depending on internal structures, which may change at any time.
Keep in mind, this attached example is only designed for a single client!
If you have multiple clients, we would have to store the iSliderValueOnMouseDown in an array.
Best regards,
Marcel
ResetSliderValue.project [175.13 KiB]
Hi, and thanks for reply.
I am having trouble pointing to my slider. It has ID 0 i my visu. Is it suppose to be located in the Input Assistant?
Hello,
If you can do it the way M.Prestel shows it i'm sure it is a better approach. If you can't do it that way maybe you could upload a sample project for me to take a look at. As Marcel mentions Pointers is not the best approach but I'm using 3.5.5.4 and don't know if his approach is available in this version. Haven't had time to look into it thoroughly. What version of CoDeSys are you using also helps.
Regards,
CB