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

Web and WebWorks Development

Reply
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone
Accepted Solution

BB10 WW Native Extension events

I've written a Virtual Keyboard extension which works nicely as far as it goes.

 

I wanted to add the Virtual Keyboard events into the extension so when the system does something with the VK I know about it and also to track the height of the VK properly as virtualkeyboard_get_height is useless

 

BB10-WebWorks-Framework includes only one API with a fully fledged event loop and that's BBM (which is vast overkill as an example for my simple little event)

 

Anyway - I cobbled together something that should just about work (I thought) and it kills my extension :smileysad:

 

Even if the hooks to start and stop the event handler are commented out it dies (it goes so far as to load the extension then say it can't find it - presumably owing to it crashing)

 

I really just need a nice simple event loop example

 

If you want to look at the broken event stuff and point out my dumb error please do

 

Everything is on https://github.com/peardox/bb10webworks-ext/tree/master/VKeyboard

 

I've got two more extensions I wanna write after I get this one working and they both also require event loops

 

I've applied for GitHub access so when I get these sussed they will end up in Community APIs




Click the like button if you find my posts useful!
Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 WW Native Extension events

My knowledge of how to do event loops is as such:

https://developer.blackberry.com/native/reference/bb10/com.qnx.doc.bps.lib_ref/com.qnx.doc.bps.lib_r...

 

However it appears by looking at your code, you are trying to do that.

 

I've asked for help on this one with some native/C++ experts.  Hoping I can get you some more info.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: BB10 WW Native Extension events

Thanks Adam

 

Yeah - I followed the only guides I could find but sadly the only full example was BBM

 

Many of the cooler APIs need to watch events and digging around NDK / non-visual CASCADES APIs there are some really useful extensions just itching to be written

 

If someone can spot my stupid mistake I'll have a template I can easily adapt to other uses

 

I've got an onExit I'm dying to write... It won't stop exit, it gives you a requestable up to 30 seconds tidy-up according to docs which is a highly desirable feature and looks simple to implement (if I can write event loops...)




Click the like button if you find my posts useful!
Please use plain text.
BlackBerry Development Advisor
bryanhiggins
Posts: 190
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: BB10 WW Native Extension events

About onExit, we do have an exit event and a hook into navigator_extend_terminate in webplatform. It works to keep the process running, but the webview is already destroyed. I did not try this from a native extension, but results should be the same - native code keeps running, but you can't run any clean up JavaScript.

 

https://github.com/blackberry/BB10-WebWorks-Framework/issues/393

 

https://github.com/blackberry-webworks/BB10-WebWorks-Framework/commit/fb591e799dd3e285f8eb7c75bef4f9...

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: BB10 WW Native Extension events

[ Edited ]

Hi,

 

Your c++ isn't complete - your (most likely) crashing due to a missing function; one problem with writing an extension is that missing functions are not identified (it's a library! some other library might have that code!)

 

You have not defined:

 

webworks::TemplateNDK::SendEndEvent();

 but, you have called it.

 

You need to add the class name here to have implemented each function;

 

static void SendEndEvent(){
	virtualkeyboard_request_events(0);
}

 

I strongly recommend trying to compile your extension as/into a Cascades project - missing functions are identified instantly at the linking stage - and you get the richer debugging...

 

Doesn't have to be Cascades though could be any stand alone C++ executable, made with the tooling of your choice...

 

Hope this helps!

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: BB10 WW Native Extension events

So, the app window is destroyed before the onExit message is passed?

 

How about this for a (not as useful) concept...

 

onPause event gets fired. onPause handler sends any critical state to onExit extension - it's now in NDK-space

 

If user has merely backgrounded to do something else for a while and returns to app all well and good

 

If user exits - and here's the unknown bit - is extension still alive after webview destroyed?

 

If so then extension can trap exit and serialize it's buffer then save it out. When app it restarted clean-up data is available on request from extension.

 

i.e. you do clean-up the next time you start the app before you do anything else thus restoring state :smileyhappy:

 

Back to front but potentially viable...

 




Click the like button if you find my posts useful!
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: BB10 WW Native Extension events

Thanks hugely - I see it now

 

I knew it'd be something stupidly simple

 

Just prefix sendEndEvent with TemplateNDK:: and cross my fingers :smileyhappy:

 

I'm on a fairly steep learning curve here - fancy missing something so obvious...

 




Click the like button if you find my posts useful!
Please use plain text.
BlackBerry Development Advisor (Retired)
robbieDubya
Posts: 418
Registered: ‎07-18-2012
My Device: Q10
My Carrier: Bell Canada

Re: BB10 WW Native Extension events

:smileyindifferent: totally not going to say how long it took me to find it the first time I did that...

--
Rob is no longer associated with BlackBerry.
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: BB10 WW Native Extension events

It's a total can't see the trees for the forest situation - and my screw-up is documented for all the world to see :smileysad:

 

App compiles properly now

 

 

 




Click the like button if you find my posts useful!
Please use plain text.
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: BB10 WW Native Extension events

Cool

 

I _appear_ to have accidentally proved that an extension still lives after the app is closed. Its permanently in a termination event by the look of it - icon is transparent forever and unresponsive, rest of the device works fine

 

In other words I appear to have a little bug that _may_ prove rather useful later on as part of an onExit replacement (onRestart?) as postulated above

 

Reboot device (yet again) and fix thread termination time

 

Ain't extension development fun :smileyhappy:




Click the like button if you find my posts useful!
Please use plain text.