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
Developer
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10
My Carrier: none

MapView as one of several controls inside ScrollView on Page

[ Edited ]

Hello.

 

I have a Page that contains a Scrollview, which in turn contains a MapView along with some other controls. Something like in the example below.

 

(a) When the user slides (on an area of teh page not containing the MapView)  from left to right the page should slide to the right (peekEnabled), and when the user slides up/down then the ScrollView should scroll up/down.

This works fine.

 

(b) When the user slides (touches) in the MapView  -only- the MapView should pan/zoom. the Page should not slide to the right/left and the scrollview should not scroll (the mapview is handling the gestures).

 

Unfortunatley in case (b) the page does slide and the scrollview does scroll also.

 

Presumably theres a simple way of telling Cascades not to propagate the Events to the parent ScrollView if the MapView has handled them?  I read

https://developer.blackberry.com/native/documentation/cascades/dev/touch/touch_propagation.html

but cant seem to get it to work quite right. Am I missing something?

How should I ammend the sample code to get things to work as desired?

 

Thanks in Advance

 

 

MyPage::MyPage)
  : Page(Mw)
{
    setPeekEnabled(true);
ScrollView * Sv = new ScrollView(); setContent(Sv);
    Container * Cont = new Container();
        Sv->setContent(Cont);
// create some simple controls above the MapView Label * Lab = new Label(Cont);
//..etc

MapView * Mv = new MapView(Cont);

// create some Controls below the MapView
Label * OtherStuff = new Label(Cont);
// etc ....
}

 

Highlighted
Retired
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: MapView as one of several controls inside ScrollView on Page

Try setting the OverlapTouchPolicy of the MapView to Deny.

 

https://developer.blackberry.com/native/reference/cascades/bb__cascades__overlaptouchpolicy.html#enu...

 

Shadid

Developer
Developer
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10
My Carrier: none

Re: MapView as one of several controls inside ScrollView on Page

Hi Shadid.

 

Thanks for the suggestion.

Doesnt seem to work however.

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

Re: MapView as one of several controls inside ScrollView on Page

[ Edited ]

I've had a JIRA report on this in for over a year now, the latest response was that this has improved in the latest version.

 

https://www.blackberry.com/jira/browse/BBTEN-811

 

There seems to be no easy way to override the left-to-right peek on a control or customcontrol any other way than to set peekEnabled.

 

The thread from when I had a similar problem a year ago...

 

http://supportforums.blackberry.com/t5/Native-Development/Overriding-peek-for-customcontrol/m-p/2118...


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: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: MapView as one of several controls inside ScrollView on Page

Not ideal but this seems to be the only way to do it currently...

 

Page {

    Container {

        Label {
        	minHeight: 200.0
        	maxHeight: 200.0
        	text: "Drag me left to right - Peek Enabled"
        }

        Label {
            id: lab

            minHeight: 200.0
            maxHeight: 200.0        
            text: "Drag me left to right - Peek Disabled"

            onTouch: {
            	if (event.isDown() || event.isMove()) {
                    lab.text = "Drag me left to right - Peek Disabled (moving)"
            	    navigationPane.peekEnabled = false;
                } else if (event.isUp() || event.isCancel()) {
                    navigationPane.peekEnabled = true;   
                    lab.text = "Drag me left to right - Peek Disabled";     	    
            	}
            }
        }
    }

}

 


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
Developer
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10
My Carrier: none

Re: MapView as one of several controls inside ScrollView on Page

Thanks for the helpful suggestion.

I had tried something like this already (with the addition of listeing to touchEnter/Exit) but its unfortunately not sufficient, since as I said its not just the page peeking thats the problem but also the scrollview (contaning the map view as well as other controls) scrolling.

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

Re: MapView as one of several controls inside ScrollView on Page

You would need to set the overlapproperties and touchpropagation properties for each ancestor in the hierarchy unfortunately.

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: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: MapView as one of several controls inside ScrollView on Page

[ Edited ]

A ScrollView / MapView combination is not something I've played with but similar to the peek solution you could try disabling the ScrollView by setting the ScollMode property within the touch handler...

http://developer.blackberry.com/native/reference/cascades/bb__cascades__scrollviewproperties.html#pr...

 

Other design solutions would be to do away with a scrollview and place the MapView on a seperate page or implement a sliding drawer mechanism if you want to keep it on the same page.

 

[Edit] I've added the missing JIRA link (although JIRA is still down) and a thread on the peek problem from a year ago in the post above.


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
Developer
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10
My Carrier: none

Re: MapView as one of several controls inside ScrollView on Page

> You would need to set the overlapproperties and touchpropagation properties for each ancestor in the hierarchy unfortunately.

 

I dont think this would work. (The Scrollview and peeking should function when the user is interacting with controls outside the mapview.

 

Listening to to the touch gestures in the mapView and manually disabling the scrollview::scrollProperties and NavigationPane:Smiley TongueeekEnabled seems to be  a good workaround  though. Thanks for the helpful suggestion.

Developer
Developer
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10
My Carrier: none

Re: MapView as one of several controls inside ScrollView on Page

There should be a good way to get the MapView to just "consume" the events so that they dont propagate anywhere else (and thereby not to have to manually set/reset the peekEnabled and ScrollProperties).

I would have thought calling TouchEnterEvent::setAccepted(true) would have done the trick, but strangely it didnt