Focus lost event with hyperlink in Browser [message #1373941] |
Thu, 22 May 2014 11:50 |
Matthias Nick Messages: 197 Registered: August 2013 |
Senior Member |
|
|
Hi,
I have a problem with a hyperlink in the Browser widget. A simplified example is below:
I have an editable table and a Browser widget which contains a hyperlink. When I click inside a table's cell, the celleditor opens and has the focus.
SWT:
When I click on the hyperlink the celleditor closes because the hyperlink gains focus (on mousepressed)
RAP:
The celleditor does not close because the link does not gain the focus (there is no focusOut event on the table/celleditor)
Subsequently this leads to a "Widget is disposed" exception in
org.eclipse.jface.viewers.ColumnViewerEditor.cancelEditing()
Control control = cellEditor.getControl();
if (control != null && !viewer.getControl().isDisposed()) {
if (mouseListener != null) {
control.removeMouseListener(mouseListener); //control is disposed here!
Because control is disposed here
Maybe it is related to http://www.eclipse.org/forums/index.php/m/917900/?srch=focus#msg_917900 ?
[Updated on: Thu, 22 May 2014 13:56] Report message to a moderator
|
|
|
|
|
Re: Focus lost event with hyperlink in Browser [message #1384144 is a reply to message #1376078] |
Wed, 28 May 2014 08:32 |
Matthias Nick Messages: 197 Registered: August 2013 |
Senior Member |
|
|
Hi,
I just tried the following snippet:
<html>
<body>
<select id="selectfield">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>
<input type="text" id="textfield"></input>
<iframe src="iframe.htm" width="90%" height="400" name="name"></iframe> <!-- here a hyperlink is contained -->
<script type="text/javascript">
document.getElementById("selectfield").onblur = function () { alert("focus lost!"); }
document.getElementById("textfield").onblur = function () { alert("focus lost!"); }
</script>
</body>
</html>
When I click on the hyperlink in the IFrame the focusLost event is sent as expected. Is there no way that RAP can achieve the same behaviour?
[Updated on: Mon, 02 June 2014 08:40] Report message to a moderator
|
|
|
|
|
|
Re: Focus lost event with hyperlink in Browser [message #1386260 is a reply to message #1385287] |
Mon, 16 June 2014 08:43 |
Matthias Nick Messages: 197 Registered: August 2013 |
Senior Member |
|
|
Hi,
I tried to manually send a focusLost event. I created a new BrowserFunction which sends a FocusOut event. However it does not work... Did I do anything wrong here?
return new BrowserFunction(m_browser, getHyperlinkFunctionName()) {
@Override
public Object function(Object[] arguments) {
Control focusControl = Display.getDefault().getFocusControl();
if (focusControl != null) {
System.err.println("sending focus lost event to " + focusControl);
Event event = new Event();
event.type = SWT.FocusOut;
event.widget = focusControl;
event.display = Display.getDefault();
focusControl.notifyListeners(SWT.FocusOut, event);
Event event2 = new Event();
event2.type = SWT.FocusIn;
event2.widget = m_browser;
event2.display = Display.getDefault();
m_browser.notifyListeners(SWT.FocusIn, event2);
}
[Updated on: Mon, 16 June 2014 08:48] Report message to a moderator
|
|
|
|
Re: Focus lost event with hyperlink in Browser [message #1386293 is a reply to message #1386265] |
Mon, 16 June 2014 12:03 |
Matthias Nick Messages: 197 Registered: August 2013 |
Senior Member |
|
|
Hi Ivan,
thanks for your reply. Yes the BrowserFunction is working.
Is "Control.forceFocus()" somehow different than really clicking into a field by mouse?
Note:
I have a control (A) which has the focus and attached a focusLostListener.
a) Now I click into another field (B) by mouse, the focusLostListener is called. When I look at the currently focused field: getDisplay().getFocusControl() B is focused, as expected.
b) When I do a "B.forceFocus()" in the BrowserFunction, the focusLost listener is called but getDisplay().getFocusControl() returns A
[Updated on: Mon, 16 June 2014 12:04] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06685 seconds