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
Trusted Contributor
babyblue_lee
Posts: 130
Registered: ‎08-10-2010
My Device: Not Specified
Accepted Solution

How to mimic the event of clicking a Field? e.g. 'Mail' icon

I can think of a complicated way.

 

1. Use API API net.rim.device.api.ui.UiApplication.getActiveScreen to get the active screen.

2. Use API net.rim.device.api.ui.Screen.getFieldCount  to retrive the total number of Fields on that screen; or use getFieldWithFocusIndex() to retrieve the index of focused Field.

3. Use getField(int index) to retrive the specific Field.  Then click the Field with methods like 'KeyDown()'.

 

Is there any easier way to do this?

 

Thanks.

Please use plain text.
Regular Contributor
Plato
Posts: 71
Registered: ‎07-11-2010
My Device: Bold 9000
My Carrier: none

Re: How to mimic the event of clicking a Field? e.g. 'Mail' icon

If you are allowed to inject events, following code should do the trick

 

 

invokeAndWait(new Runnable () {
  public void run() {
    EventInjector.NavigationEvent e;

    e = new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_CLICK, 0, 0, KeypadListener.STATUS_NOT_FROM_KEYPAD);
    EventInjector.invokeEvent(e);

    e = new EventInjector.NavigationEvent(EventInjector.NavigationEvent.NAVIGATION_UNCLICK, 0, 0, KeypadListener.STATUS_NOT_FROM_KEYPAD);
    EventInjector.invokeEvent(e);
  }});

 

 


-----
A good decision is based on knowledge and not on numbers.
Please use plain text.
Trusted Contributor
babyblue_lee
Posts: 130
Registered: ‎08-10-2010
My Device: Not Specified

Re: How to mimic the event of clicking a Field? e.g. 'Mail' icon

Thanks.

 

I found this API defination.

public EventInjector.NavigationEvent(int event,
                                     int dx,
                                     int dy,
                                     int status)

 

But how to determine the dx,dy amout beforehead?

 

 

Please use plain text.
Regular Contributor
Plato
Posts: 71
Registered: ‎07-11-2010
My Device: Bold 9000
My Carrier: none

Re: How to mimic the event of clicking a Field? e.g. 'Mail' icon

For movement events, dx and dy are the amount that you want to scroll in that direction (up / 1 - means one position up)

 

For click/unclick - I believe that they do not matter.


-----
A good decision is based on knowledge and not on numbers.
Please use plain text.