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

WebView with context menu

Hello.

 

Id like to have a context menu appear (as a "popup" ie not usually visible) in an app that shows a webview.

The code below seems to work fine for an ImageView, but if I use a WebView instead it doesnt. 

(1) the menu only appears when the user (long) holds on a piece of text.  Id like it to appear if they long hold down anywhere on the screen.

(2) Other items are alredy in the context menu (presumably from webview itself), such as "open in Browser". Is there some way to remove some reliable or all of these?

 

Any help would be greatly appreciated. (code below)

 

import bb.cascades 1.0

Page {
    Container {
        layout: DockLayout {
        }
        //---------------------------------------------
      
        //----------------------------------------
        ScrollView {
            id: scrollView
            scrollViewProperties {
                scrollMode: ScrollMode.Vertical
                pinchToZoomEnabled: true
            }
            //layoutProperties: StackLayoutProperties { spaceQuota: 1.0 }

            Container {
                background: Color.LightGray
                WebView { url: "http://www.google.com"
                // ScrollView { imageSource: "asset:///icon.png" 
                    //-----------------------------------------------
                    contextActions: [
                        ActionSet {
                            title: "Animations"
                            subtitle: "Choose your animation"
                            ActionItem {
                                title: "Slide"
                                imageSource: "asset:///icon.png"
                                onTriggered: {
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
}

 

 

Best Wishes

Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)

Re: WebView with context menu

There is a lot of different content in a WebView, what do you want to show the user in the context menu? Might be confusing for him. I would recommend the ActionBar instead.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Developer
Developer
p8
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10

Re: WebView with context menu

P.S

"ScrollView" in the above snippet should have been "ImageView"

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

Re: WebView with context menu

Hello zezke

 

Thanks for the suggestion, but I dont want to have to show the action itenm all the time.

Theres too little space already on a q10 and this would be wasting about 20% of that.

Also theres already a context menu in the webview by default, and the way it shows itself doesnt confuse users I think.

 

Best Wishes.

Declan