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
Highlighted
Developer
Posts: 64
Registered: ‎09-10-2009
My Device: Z10, Bold 9700
My Carrier: O2 Germany
Accepted Solution

Detect UI changes of page

I have a sheet with multiple input fields on it.

 

When the user presses the close button of the sheet, I want to perform a check if the user has made any changes in which case I would display a confirmation dialog before closing the sheet and discarding the changes.

 

Is there any way to globally detect changes on the sheet or page?

 

On the old Java-based BBOS there was a method Screen.isDirty() that could be used for this purpose:

http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/ui/Screen.html#isDirty%28%29

----

My Twitter: @hendrik_dev
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Detect UI changes of page

No there's not.

 

What you can do though is hook into the onTextChanging signal of each one and update a global variable to indicate there has probably been a change.

 

The way I did it however was to subclass the various controls and then have that signal's slot check if the text had actually changed then emit my own signal  indicating there had been a definate change.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 64
Registered: ‎09-10-2009
My Device: Z10, Bold 9700
My Carrier: O2 Germany

Re: Detect UI changes of page

Thanks, in this case I'll have to implement the check myself.

Your suggestion is a good idea. However, since I already have an object containing the initial data, I'll simply compare all of its attributes upon closing the sheet.
----

My Twitter: @hendrik_dev
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Detect UI changes of page

That would also work. Smiley Happy


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,168
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: Detect UI changes of page


BBSJdev wrote:

No there's not.

 

What you can do though is hook into the onTextChanging signal of each one and update a global variable to indicate there has probably been a change.

 

The way I did it however was to subclass the various controls and then have that signal's slot check if the text had actually changed then emit my own signal  indicating there had been a definate change.

 


What I do is keep a "dirty" boolean on each page, set it to false on page open, and set it to true in the on<value>Changed slot for each control on the page. That way when the page is closed the dirty flag will be true if ANY of the controls on the page were updated.



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Detect UI changes of page

Definately another way to do it.

 

However it doesn't cope with the user changing the value then changing their mind and resetting it back.

There were many reasons for me to do a custom control this was just one of them.

 

I'm not saying it's the best approach for everyone but it was for me.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.