CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Feb 18, 2020 7:52 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Oct 24, 2019 6:58 am 
Offline

Joined: Thu Oct 24, 2019 6:19 am
Posts: 3
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 8)


Top
   
PostPosted: Thu Oct 24, 2019 7:01 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 189
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


Top
   
PostPosted: Thu Oct 24, 2019 7:05 am 
Offline

Joined: Thu Oct 24, 2019 6:19 am
Posts: 3
m.prestel wrote:
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.


Top
   
PostPosted: Thu Oct 24, 2019 9:41 pm 
Offline
Frequent User
Frequent User

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 126
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...:
Code:
VAR_INPUT
    siSlider1POS : SINT := 0; (*Slider value*)
END_VAR
VAR
    xInit : BOOL := TRUE;
    pSlider1 : POINTER TO visufbelemslider;  (*Library part of "System_VisuElemsWinControls that should already be in your project*)
END_VAR

IF xInit THEN
    xInit := FALSE;
    pSlider1 := ADR(__VisuInitInstantiation_Gvl.__VisuInitInstantiation_Instance.inst__Home.GEN_Instance_2._visufbelemslider[0]); (*Pointer to slider*)
END_IF

IF NOT pSlider1^.m_bDragged THEN
    siSlider1POS := 0; //Set slider value to 0 when slider is not being dragged.
END_IF


Top
   
PostPosted: Fri Oct 25, 2019 8:51 am 
Offline
Frequent User
Frequent User

Joined: Thu Aug 30, 2018 8:40 am
Posts: 189
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


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Tue Oct 29, 2019 1:49 pm 
Offline

Joined: Thu Oct 24, 2019 6:19 am
Posts: 3
Comingback4u wrote:
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...:
Code:
VAR_INPUT
    siSlider1POS : SINT := 0; (*Slider value*)
END_VAR
VAR
    xInit : BOOL := TRUE;
    pSlider1 : POINTER TO visufbelemslider;  (*Library part of "System_VisuElemsWinControls that should already be in your project*)
END_VAR

IF xInit THEN
    xInit := FALSE;
    pSlider1 := ADR(__VisuInitInstantiation_Gvl.__VisuInitInstantiation_Instance.inst__Home.GEN_Instance_2._visufbelemslider[0]); (*Pointer to slider*)
END_IF

IF NOT pSlider1^.m_bDragged THEN
    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?


Top
   
PostPosted: Thu Oct 31, 2019 6:52 pm 
Offline
Frequent User
Frequent User

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 126
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited