As a WebWorks developer I should be able define a custom context menu for a set of DOM elements #184

Closed
jeffheifetz opened this Issue Aug 7, 2012 · 15 comments

Projects

None yet

6 participants

@jeffheifetz
Contributor

As a webworks developer I can define a custom context by defining a custom attribute on my dom elements. The attribute context should apply for both the element and its children. A child's context WILL overwrite any custom context declared by its parent.

It is expected that webkit will return the same context object as usual with a custom context field if one is applicable.

We have chosen the data-webworks namespace for webworks custom attributes to remain similar but distinct from bbui.js
<div data-webworks-context="MyContext"> .... </div>.

Then when the user adds a custom context menu element using this new context like so

 var myItem = {actionId: 'MyItem', label: 'My Item', icon:'http://mysite.com/icon.png'},
        contexts = ["MyContext"];
 blackberry.ui.contextmenu.addItem(contexts, myItem, function() { console.log('hi') });

To allow the user to add traditional webworks context menu items (copy, paste, cancel, openLink, etc.) we will expose their action ids as constants. This allows the user to either use the default action like so
blackberry.ui.contextmenu.addItem(contexts, {actionId: blackberry.ui.contextmenu.COPY_ACTION});
Or if they just want the platform default icons and labels but a custom callback they can do the following
blackberry.ui.contextmenu.addItem(contexts, {actionId: blackberry.ui.contextmenu.COPY_ACTION}, callback);
Default actions involving the clipboard are based on whats currently selected. The user can change the selection to control these actions.

The user will automatically be registered for context items from the menu-service based on the original context selected.

Stretch Goals:

Provide a way for the user to give a heading/subheading that would be used when one isn't provided by the menu service.
Provide a way for the user to give a different menu-service lookup based for the context

These can be either through

  1. A new custom attribute
  2. A structure on the original attribute
  3. A JS API like the following -
    blackberry.ui.contextmenu.setCustomContextAttributes(<CONTEXT_ID>, { defaultTitle: "foo", defaultSubTitile: "foo", mimeType: "foo", data: "foo"})
@astanley
astanley commented Aug 7, 2012

I would like to request that the blackbery.ui.contextmenu object offers both show() and hide() methods - if possible - to enable the developer to programatically invoke those events.

@nukulb
Contributor
nukulb commented Aug 7, 2012

show method would need context, because this menu is based on context, what context would the user add?

@jeffheifetz
Contributor

@astanley I think this should be a separate issue, but aside from that, even the hide() method would be useless without an onContextMenuDisplayed event (otherwise how would they know when to call it?). As per the show(), as Nukul mentions it would require a context which is more complicated than just the String value as it would include items given from the browser, header and subheader text and more.

@astanley
astanley commented Aug 8, 2012

Are we not planning to add any custom menu items to a context menu? I would imagine this technique could be an easy way to present 1st time users with getting started tips e.g. menu items for login or help or tutorials

@kwallis
Member
kwallis commented Aug 8, 2012

Perhaps we are confusing the UI concepts here? The context menu only gets shown on a long-press on an item in the application. It should not appear/disappear in other scenarios. If you want to present "actions" in other scenarios, that is what you use a swipedown menu, or action bar for. This user story only covers the Context Menu.

Ken Wallis

Product Manager – BlackBerry WebWorks

Research In Motion

(905) 629-4746 x14369


From: Adam Stanley [notifications@github.com]
Sent: Wednesday, August 08, 2012 9:33 AM
To: blackberry/BB10-WebWorks-Framework
Subject: Re: [BB10-WebWorks-Framework] As a WebWorks developer I should be able define a custom context menu for a set of DOM elements (#184)

Are we not planning to add any custom menu items to a context menu? I would imagine this technique could be an easy way to present 1st time users with getting started tips e.g. menu items for login or help or tutorials


Reply to this email directly or view it on GitHubhttps://github.com/blackberry/BB10-WebWorks-Framework/issues/184#issuecomment-7583550.


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

@jeffheifetz
Contributor

@astanley We already have an api for adding custom menu items to an existing context. The API is defined here - blackberry-webworks/BB10-Webworks-API#37 and the docs can be found here - http://blackberry-webworks.github.com/WebWorks-API-Docs/WebWorks-API-Docs-next-BB10/view/blackberry.ui.contextmenu.html#.addItem

@astanley
astanley commented Aug 8, 2012

yes I think I might be getting my menus confused after all. So the context menu is designed to be displayed ONLY when the user touch-holds the screen. If so that eliminates my need for a show() method. The

However what about a hide() or close() method? Or is this something that a user must manually close? Say the developer wants to 'close' a context menu when an application event happens (timeout / playback begins / remote context target no longer available - e.g. "P2P / socket connection"?

@jeffheifetz
Contributor

Context menus in webworks are modal and are meant to stop the user from interacting with the underlying app until the user dismisses them. I do not feel this fits with the idea of hiding them.

@jeffheifetz jeffheifetz was assigned Aug 9, 2012
@jeffheifetz
Contributor

@kwallis I have updated the description, is this acceptable?

@kwallis
Member
kwallis commented Aug 15, 2012

We will need to ensure that the menu item ordering criteria is respected for custom contexts, I.e. Application added items appear before the "standard" Web platform items (the ones we are defining constants for, which should appear before menu service items.

Did we determine whether menu service will return third-party defined menu items? Iguess that is the second "stretch" goal? If so, then I would say this really needs to be part of the primary goals.

Otherwise I am good with this.

@nunodonato

As a developer, if I'm able to add custom items to context menus, what happens if the list of actions is bigger than the screen? (considering, for example, the keyboard model with smaller screen).
Will the user have to open the context menu and then scroll through it? (doesn't sound like a good UX) Or will it have some kind of overflow button?

@nukulb
Contributor
nukulb commented Sep 6, 2012

There is an overflow button for more than 7 items
~Nukul

From: Nuno Donato [mailto:notifications@github.com]
Sent: Thursday, September 06, 2012 04:01 AM
To: blackberry/BB10-WebWorks-Framework BB10-WebWorks-Framework@noreply.github.com
Cc: Nukul Bhasin
Subject: Re: [BB10-WebWorks-Framework] As a WebWorks developer I should be able define a custom context menu for a set of DOM elements (#184)

As a developer, if I'm able to add custom items to context menus, what happens if the list of actions is bigger than the screen? (considering, for example, the keyboard model with smaller screen).
Will the user have to open the context menu and then scroll through it? (doesn't sound like a good UX) Or will it have some kind of overflow button?


Reply to this email directly or view it on GitHubhttps://github.com/blackberry/BB10-WebWorks-Framework/issues/184#issuecomment-8325254.


This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

@nukulb
Contributor
nukulb commented Oct 5, 2012

I think for custom context we need to be able to pass a custom mime-type to menu srvice so that the platform can determine if there is anything out there that can handle this mime-type.

for example

if I am showing a list of pdf files, I want the mime-type to vapplication/pdf (or something like that)

the menu service should call then.

@sleroux
Contributor
sleroux commented Oct 5, 2012

The current description requires your custom context element to contain an element which has a defined context (ie. a div tag with data attribute for custom context with an img tag inside). This doesn't seem to imply a 'custom' context but more a context 'override'. Wouldn't a custom context not depend on an existing context to be invoked?

@jamesjhedley jamesjhedley referenced this issue in blackberry-webworks/BB10-WebWorks-Framework Nov 24, 2012
Closed

Custom context menu support [new API defineCustomContext] #292

@jamesjhedley jamesjhedley pushed a commit to blackberry-webworks/BB10-WebWorks-Framework that referenced this issue Nov 26, 2012
James Keshavarzi Created new API for custom context menus [defineCustomContext]
Fixes blackberry/BB10-WebWorks-Framework#184

Reviewed By: Rowell Cruz <rcruz@rim.com>
Tested By: Tracy Li <tli@rim.com>
2c46e59
@jamesjhedley jamesjhedley pushed a commit to blackberry-webworks/BB10-WebWorks-Framework that referenced this issue Nov 27, 2012
James Keshavarzi Created new API for custom context menus [defineCustomContext]
Fixes blackberry/BB10-WebWorks-Framework#184

Reviewed By: Rowell Cruz <rcruz@rim.com>
Tested By: Tracy Li <tli@rim.com>
69cd515
@ejzn ejzn added a commit to blackberry-webworks/BB10-WebWorks-Framework that referenced this issue Dec 12, 2012
@ejzn ejzn Adding override API + manual tests to ui.contextmenu namespace. Provides
developers the ability to override parts of default system actions if
they wish to implement their own share/Copy etc.

Additiional Capabilities on to Issue: blackberry/BB10-WebWorks-Framework#184
70d6912
@nukulb nukulb pushed a commit that referenced this issue Dec 13, 2012
@ejzn ejzn + Nukul Bhasin Adding override API + manual tests to ui.contextmenu namespace. Provides
developers the ability to override parts of default system actions if
they wish to implement their own share/Copy etc.

Additiional Capabilities on to Issue: blackberry/BB10-WebWorks-Framework#184

Reviewed By: Rowell Cruz <rcruz@rim.com>
Tested By: Igor Shneur <ishneur@rim.com>
4b33d1c
@jeffheifetz
Contributor

Shipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment