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

Java Development

Reply
Contributor
Posts: 11
Registered: ‎12-10-2010
My Device: Not Specified

Query Regarding EventInjector for on-screen keyboard

Hello Friends,

 

I have and requirement to inject key events and touch events (if touch screen is available) in blackberry devices from Java program. I am able to do it successfully using the EventInjector API.

 

But in case of touch screen devices, such as storm, when the on-screen key board is visible then the EventInjector API is failing to inject those key events i.e. when I use the following code over the on-screen keyboard no event is injected. The code is as below:

 

EventInjector.TouchEvent downEvent = new EventInjector.TouchEvent(TouchEvent.DOWN, coordinates[0], coordinates[1], -1, -1, -1);  //Touch the screen

 

EventInjector.TouchEvent clickEvent = new EventInjector.TouchEvent(TouchEvent.CLICK, coordinates[0], coordinates[1], -1, -1, -1); //Click the screen

 

EventInjector.TouchEvent unclickEvent = new EventInjector.TouchEvent(TouchEvent.UNCLICK, coordinates[0], coordinates[1], -1, -1, -1); //Unlick the screen

 

EventInjector.TouchEvent upEvent = new EventInjector.TouchEvent(TouchEvent.UP, coordinates[0], coordinates[1], -1, -1, -1); //Lift finger from the screen

 

// Invoke the touch events

EventInjector.invokeEvent(downEvent);

EventInjector.invokeEvent(clickEvent);

EventInjector.invokeEvent(unclickEvent);

EventInjector.invokeEvent(upEvent);

I have ensured that the co-ordinates above is corresponding to a particular key in the on-screen. But when the on-screen key board is not visible the above code is working fine for any other components in the device screen.

 

So requesting your valuable feedback whether the EventInjector API can be used to inject touch event over the on-screen key board or not. If it is not possible then is there any workarround to achieve this?

 

Thanks and Regards

Dipta P

 

 

BlackBerry Development Advisor
Posts: 15,263
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Query Regarding EventInjector for on-screen keyboard

Are you seeing constant failures when injecting key events or just on specific screens?

 

Event injection is no supported on every screen or application.  Event injection is not permitted on any security related screen.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 11
Registered: ‎12-10-2010
My Device: Not Specified

Re: Query Regarding EventInjector for on-screen keyboard

No, my observation is that EventInjector is working fine in most of the screens except for some applications (like BB Calculator, I guess the app prevents to do it), but it is always failing when the on-screen keyboard is visbile and I can not inject event over that on-screen key board.

 

For example consider an application having a screen containing a button and textbox. I am always able to inject event on these components, when the on-screen keyboard is visble below the above controls I am still able to inject event to the above controls but the part of the screen where the on-screen keyboard is visible the event injector is not working.

 

So I have doubt whether the on-screen keyboard is not allowing to inject event over it for any reason or not.

BlackBerry Development Advisor
Posts: 15,263
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Query Regarding EventInjector for on-screen keyboard

The Calculator application does not support event injection.

 

You should be able to inject key events into a textbox (or any field that supports text input).  This should work regardless of whether or not the on screen keyboard is shown and is the recommended approach to injecting characters.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 11
Registered: ‎12-10-2010
My Device: Not Specified

Re: Query Regarding EventInjector for on-screen keyboard

Thanks MSohm for your feedback,

 

So as per your feedback in case of text boxes and other controls I can inject events regardless of whether on-screen keyboard is visible or not, I have tested the same and the result is as per your comments.

 

But, when the on-screen keyboard is visible and the menu button is pressed, in this case some part of the menu button falls over the on-screen keyboard. When I am injecting event over the menu items which falls over the on-screen keyboard it is not working. But the same is working when the on-screen keyboard is not visible.

 

So please provide your valuable feedback whether I can inject event on menu items which is falling over the on-screen keyboard.

BlackBerry Development Advisor
Posts: 15,263
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Query Regarding EventInjector for on-screen keyboard

You should be able to inject touch events on the menu.  What BlackBerry Smartphone model and BlackBerry device software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 11
Registered: ‎12-10-2010
My Device: Not Specified

Re: Query Regarding EventInjector for on-screen keyboard

Hello MShom, the device that I am using has the following details:

Model: 9550, v5.0.0.320(Platform 4.2.0.124)

BlackBerry Development Advisor
Posts: 15,263
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Query Regarding EventInjector for on-screen keyboard

I created an application with an EditField that displayed the virtual keyboard, brought up the menu and was able to have another application inject the event into the menu.  I used the same code you have above to inject the events.

 

I was testing using the same BlackBerry model and device software version.

 

Are you seeing this in a specific application or in all applications?

 

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 11
Registered: ‎12-10-2010
My Device: Not Specified

Re: Query Regarding EventInjector for on-screen keyboard

Hello MSohm, thanks a lot for spending time on this.

 

Yes I can see the behavior in all the applications, i.e. irrespective of application I am not able to inject event over menu when the on-screen keyboard is visible (i.e. the part of the menu which is over the on-screen keyboard.

 

Since you have already have a working code it will be great help if you can post your code (if possible) so that I can check the difference with mine. Actually my code is a huge one (part of a project) and so I can post the same here

BlackBerry Development Advisor
Posts: 15,263
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Query Regarding EventInjector for on-screen keyboard

The code I used is almost identical to what you have above.  I placed mine in a TimerTask that was executed by an application running in the background.  Where are you injecting your events from?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker