|
Re: Posting event from linux doesn't work like with windows [message #1716277 is a reply to message #1716211] |
Wed, 02 December 2015 16:19 |
Eclipse User |
|
|
|
When using Display#post(), you need to inject both SWT.KeyDown AND SWT.KeyUp events. In my experience, you also need to provide keyCode values, not just the character. Modifiers (e.g., Alt, Ctrl, Shift) need to also be toggled on and then off with SWT.KeyDown/KeyUp events. I'm not entirely sure that the Browser widgets can be posted to.
|
|
|
|
|
Re: Posting event from linux doesn't work like with windows [message #1716338 is a reply to message #1716292] |
Thu, 03 December 2015 06:24 |
Nicolas DI POL Messages: 9 Registered: December 2015 |
Junior Member |
|
|
Hzllo Brian
thanks again for your help
I effectivily send two posts event, one with KeyDown, one with KeyUp
look....if I use that code in the same shell than the widget it works
public void KeyboardEvent(Browser TheBrowser, Event Theevent){
TheBrowser.setFocus();
TheBrowser.getDisplay().post(Theevent);
System.out.println("KeyEvent"+Theevent);
}
Button btnZoom_1 = new Button(compositeButtons, SWT.NONE);
btnZoom_1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
Event MyEvent = new Event();
MyEvent.type = SWT.KeyDown;
MyEvent.keyCode = 0x40000;
KeyboardEvent(MyBrowser,MyEvent);
MyEvent.type = SWT.KeyDown;
MyEvent.keyCode = 0x100002d;
KeyboardEvent(MyBrowser,MyEvent);
MyEvent.type = SWT.KeyUp;
KeyboardEvent(MyBrowser,MyEvent);
MyEvent.type = SWT.KeyUp;
MyEvent.keyCode = 0x40000;
KeyboardEvent(MyBrowser,MyEvent);
}
});
btnZoom_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnZoom_1.setText("Zoom-");
There is 4 event because it's a combinaison of CONTROL and ADD
Now I put that code into a child shell and the widget's event fires only 1 of 10
I believe you that it works but I have no idea why it works only 1 of 10.
Maybe Linux can't handle events coming from child shells?
This would kill my project
Have a nice day
Nicolas
|
|
|
Re: Posting event from linux doesn't work like with windows [message #1716417 is a reply to message #1716338] |
Thu, 03 December 2015 15:32 |
Eclipse User |
|
|
|
First, don't use embedded constants like 0x40000 and 0x100002d -- use SWT.* constants.
Second, calling setFocus() triggers a change, including sending events. Those events have to be processed before you can do your posts as the active widget may be something entirely different. You should wrap your post() calls in an asyncExec().
I believe you can add a debugging filter using Display.addFilter() to print out key events and see which widget the event is being dispatched to.
Brian.
|
|
|
|
|
Re: Posting event from linux doesn't work like with windows [message #1716729 is a reply to message #1716658] |
Mon, 07 December 2015 19:40 |
Eclipse User |
|
|
|
My guess is that the asyncExec is running before the browser actually receives the focus:
Quote:
private void writeValue(String Keypressed, int KeyCode){
System.out.println("-START-");
BrowserComponent.setFocus();
ParentDisplay.asyncExec(new Runnable(){
@Override
public void run() {
You could add a filter to output the focus change events. As you've discovered, posting events is tricky
Brian.
|
|
|
Powered by
FUDForum. Page generated in 0.03757 seconds