Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile
Accepted Solution

Slider

Hi, I have a question about slider.

 

My slider is a qml object that I want to drive programmatically from my C++ application. I've no problem with that, and everything is working here.

 

My problem is that when my app is calling mSlider->setValue(newpos), the qml send a message onValueChanged and a onImmediateValueChange. As my app is using these message too, I'm stuck in a loop.

 

I tried to raise a flag before calling the setValue, but when I get the onValueChange message, this flag has already been reset to false.

 

Any idea how I can manage this?

 

Thanks


Fred

Super Contributor
Posts: 306
Registered: ‎08-10-2010
My Device: Not Specified

Re: Slider

Hi, You can use onImmediateValueChange() method hod and this method is called when slider change its value. onValueChanged is called after onImmediateValueChange().

 

Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile

Re: Slider

Hi, 

 

I don't understand what you're trying to explain: AFAIK, onImmediateValueChange is not a method, it's a signal.

 

I'm calling the setValue method to change the value, but I don't want the onValueChanged signal to be raised (or at least I'd like to have a way to know that it has been changed by my app and not by user interaction)

 

Thanks,

 

Fred

 

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Slider

can you disconnect your slot while updating?

Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile

Re: Slider

Hi,

 

This is kind of what I tried by raising a flag true before calling the setValue and changing it to false right after the call, but it seems that the multithreading is tricking with me because when my slot is called by qml, my flag is already false.

 

Same if I disactivating the slot and reactivating right after the call.

 

What I'm trying to achieve is kind of mediaplayer, where the media is updating the slider, but the slider can update the media by user interaction.

Developer
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon
My Carrier: Play

Re: Slider

 

Hi

 

In my opinion Slider API in BB10 doesn't distinguish between the change made by user and programmatically.

 

onValueChanged and a onImmediateValueChange should send an extra value (eg. bool fromUser)

 

fromUser - true if the change was initiated by the user

Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile

Re: Slider

Obviously, this would be the best to me, but given that the flag is not working, I need to dig a bit more here.

The problem may lay in the fact that i'm using a thread to update the slider.

 

I'm pretty sure solution already exist: I don't see how it would be possible to do a mediaplayer otherwise.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Slider

why not take advantage of the fact that you know that you will be getting a new signal when you do the update.

set your "ignore" flag when you push your update out, and clear it when the changed signal is received instead of clearing it after you finish your update.  This has the advantage of letting you know that everything is synchronized by the time you clear the flag.

 

the problem is likely that the onValueChanged signal is not being emitted until after your thread completes, at which point you've already cleared your flag.

 

 

Developer
Posts: 36
Registered: ‎09-17-2012
My Device: 9810-Playbooks-devalpha-Z10
My Carrier: Free mobile

Re: Slider

Hi,

 

Simple enough to work.

 

I still have trouble to differentiate onimmediatevaluechange and onvalue changed, but I guess I can manage it.

 

Thanks a lot for your idea,

 

cheers,

 

Fred