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

BB10 WW Native Extension - events not firing

With aid spotting my stupid mistake earlier this week I've got an event loop in place

 

The actual event handling code is basically ripped from the documentation but events never actually happen meaning I can't send them back to the HTML page for processing

 

getEvents() is called from the thread's controlling function in a continuous loop - this allows the possibility of callbacks also being handled, the getEvent uses a 100ms timeout to allow this functionality (only one extra thread per Native Extension allowed).

 

Immediately after getting the event I've got a little hack that increases the height value by 1 returned by community.VKeyboard.VKgetHeight() - just so I can see where it's getting to. If this line is moved down one line inside the if(event) { .... } it never gets called, where it is caused a 100ms incremement as expected.

 

i.e. bps_get_events() is never returning an event of any kind

 

This is (almost) exactly the code flow in every example I can find but, as I say, events = never :smileysad:

 

// Event Loop

void TemplateNDK::getEvents() {
    bps_event_t *event = NULL;

    if(bps_get_event(&event, 100) == BPS_SUCCESS) {
   		vkHeight++; // Hack to see how far we get
    	if(event) {
       		if (bps_event_get_domain(event) == virtualkeyboard_get_domain()) {
   				uint16_t code = bps_event_get_code(event);

   				switch (code)
   				{
   					case VIRTUALKEYBOARD_EVENT_VISIBLE:
   					{
   						vkVisible = true;
   						m_pParent->NotifyEvent("community.VKeyboard.VKvisible");
   						break;
   					}
   					case VIRTUALKEYBOARD_EVENT_HIDDEN:
   					{
   						vkVisible = false;
   						m_pParent->NotifyEvent("community.VKeyboard.VKhidden");
   						break;
   					}
   					case VIRTUALKEYBOARD_EVENT_INFO:
   					{
   						vkHeight = virtualkeyboard_event_get_height(event);
   						m_pParent->NotifyEvent("community.VKeyboard.VKchangeHeight");
   						break;
   					}
   				}
   			}
   		}
    }
}

 

The full thing is on @ GitHub https://github.com/peardox/bb10webworks-ext/tree/master/VKeyboard




Click the like button if you find my posts useful!
New Developer
spt_genius
Posts: 7
Registered: ‎01-28-2011
My Device: BB10

Re: BB10 WW Native Extension - events not firing

To use the BPS library in your app, you should add it to your project in the QNX Momentics IDE by using the Add Library Wizard. Right-click your project and click Configure > Add Library. Select the Standard BlackBerry platform library option, and then select the BlackBerry Platform Services check box (in the Platform section).
Developer
peardox
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C

Re: BB10 WW Native Extension - events not firing

Done that already

 

The code is never called

 

Everything else works apart from the event handler

 

This leads me to believe that webplatform ain't passing messages

 

Its pretty critical I get events as without them all I can do it read/write stuff which is rather inadequate




Click the like button if you find my posts useful!