blackberry / bbUI.js

BlackBerry UI look and feel JavaScript toolkit for WebWorks
Apache License 2.0
312 stars 192 forks source link

Context menu non-functional with WebWorks 2, bbUI.js latest #996

Closed listedegarde closed 10 years ago

listedegarde commented 10 years ago

There seems to be a bug between Webworks and the BB context menu, reproducible 100% of the time.

My setup: Tested on Z10, OS 10.2. I included "webworks plugin add com.blackberry.ui.contextmenu" before compiling and installing.

The issue: Long-pressing on a bb-image-list item with context-menu enabled will display the context menu as expected, but when canceling the context menu, the image-list-item remains highlighted.

Possible pointer to a solution: Manually firing .menu.contextmenuclosed() on the context menu will unhighlight the image-list-item, so I'm guessing it has to do with the way that the context menu is sending it's "closed" state to the javavscript. I could be totally out to lunch though.

tneil commented 10 years ago

Typically this happens when the context menu plug-in prerequisite isn't configured properly. To test to see if the context menu plug-in is working I suggest changing your highlight color to a hex color like red. Then when the context menu appears it should be using the red highlight color.

If it isn't using red as the highlight color, double check your plug-in configuration.

listedegarde commented 10 years ago

I changed the highlightColor in the bb.init to '#ff0000', and the highlight colour changes to red everywhere, except the context menu as you predicted.

I think that the page you linked to is for WebWorks 1.x, as WebWorks 2.x doesn't have an ext directory in the framework directory. However just for experimentation, I added it in /BB10 WebWorks SDK 2.0.0.54/cordova-blackberry/framework/ext, and then copied the bbui directory into there, but without success. Nothing changed.

A more logical place for it to be, I believe, would be in /BB10 WebWorks SDK 2.0.0.54/plugin/ directory. So I tried that. I added com.blackberry.bbui, and then created a plugin.xml file after the style of others in that directory, and then added it to my project using webworks plugin add. I got an error in bbui.js in line 1156, whilst evaluating bb.actionOverflow.create. Either I built the xml wrong, or the plugin you linked to isn't compatible with WebWorks 2.0, or I haven't yet found the correct place to put it.

Is there any documentation for WebWorks 2.0 and the context menu with BBui.js yet? I haven't found it.

listedegarde commented 10 years ago

Well, this evening I decided I was going to learn how to switch the old WebWorks 1.x bbui plugin for the context menu into the new WebWorks 2.0. Here's the result: https://github.com/listedegarde/BBUI-Plugin

The major issue is that the app gives a black screen for about one minute. If you open the Chrome inspector during that time, you will see the error: "NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous requests." on line 823 of cordova.js. If you have any ideas, please let me know.

If you are patient, however, the app will load, and the context menu will be functional. Edit: Actually - I'm not sure if it only requires patience. I would often do a bb.pushScreen() to get to see the screen. I might have done that every time because I can't get it to function otherwise right now, so I'm trending more towards the asynchronous as being the issue.

tneil commented 10 years ago

Hmm.. Interesting. I know of others that have been able to get it working as is with WW 2.0.. I'm in the office tomorrow with access to some devices and the WebWorks team. I'll see if I can find what's going on

listedegarde commented 10 years ago

Thank you! Let me know what you find. Here's the source code that I'm using: https://github.com/listedegarde/BB10-WebWorks-Samples/tree/BBuiContextMenuBug/BfB-Boilerplate-bbUI.js-0.9x with the plugins listed in the README file. I have also tested it now on the DAC, also using 10.2. Is it possibly limited to 10.2? I'll have to pull out my device with 10.1.

BBui is compressed in that fork, but using the uncompressed version (naturally) yields the same results; just easier to debug. :) Leaving out my bbui plugin that I made last night gives the results mentioned in the original post.

listedegarde commented 10 years ago

They say, "Where there's a will, there's a way", and it's true. :) I finally got my bbui context menu working without a 60+ second delay when starting the app. Here is the final plugin code: https://github.com/listedegarde/BBUI-Plugin

Simply copy the com.blackberry.bbui directory to your "/BB10 WebWorks SDK /plugin" directory, and then include it using "webworks plugin add com.blackberry.bbui." Tested on Blackberry 10.2, DAC.

Would you like me to request a pull request as a new WebWorks 2.0 branch over here: https://github.com/blackberry/bbUI.js/tree/master/pkg/bb10 ?

tneil commented 10 years ago

I've been doing some code merging and testing on WebWorks 2.0.. the Context menu is my last thing to bring across.. I'm going to give your code a try :+1:

tneil commented 10 years ago

I do have a 2.0 branch open. If you do want to send a pull request for your changes that would also be great :)

listedegarde commented 10 years ago

I'm not quite sure if that push is what you had in mind: it is rather hidden in the pkg directory, but I didn't see a more logical place to put it. Let me know if you'd like me to change something.

tneil commented 10 years ago

I just merged it in.. thanks for the contribution!

I'll give it a try this morning and update the screen shot in the readme

tneil commented 10 years ago

Cool.. I just needed to make sure that I added com.blackberry.ui.contextmenu to my sample and it is working beautifully!! Thanks again for your contribution :+1:

listedegarde commented 10 years ago

Nice, and thank you! I'm glad I finally managed to do something useful. :smile: I should really add a line at the bottom of the readme here: https://github.com/blackberry/bbUI.js/tree/10.3/pkg/bb10 mentioning that one must add com.blackberry.ui.contextmenu as well as com.blackberry.bbui. Would you like me to do that for both the master branch and the 10.3 branch, or just the 10.3? Or will you do it when you add a screenshot, or are you leaving the screenshot out after all?

tneil commented 10 years ago

If you can make that change and send a pull request to the 10.3 branch that would be great!