Skip to content

Commit 00e8750

Browse files
author
soheil_h_y
committed
1. setFocus fixed for all widgets.
1 parent a99bb14 commit 00e8750

File tree

2 files changed

+15
-0
lines changed
  • sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt

2 files changed

+15
-0
lines changed

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/internal/browser/OS.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private OS() {
4646

4747
public static boolean isOpera = false;
4848

49+
4950
/**
5051
* @j2sNative
5152
var os = $wt.internal.browser.OS;
@@ -778,4 +779,9 @@ public static Point getImageSize(Image image) {
778779
}
779780
return new Point(w, h);
780781
}
782+
783+
public static void SetFocus(Element handle) {
784+
handle.focus();
785+
}
786+
781787
}

sources/net.sf.j2s.java.org.eclipse.swt/src/org/eclipse/swt/widgets/Control.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,13 @@ public boolean forceFocus () {
661661
if (display.focusEvent == SWT.FocusOut) return false;
662662
Decorations shell = menuShell ();
663663
shell.setSavedFocus (this);
664+
System.out.println("1" + isEnabled() + " " + isVisible() + " " + handle.style.visibility + " " + getVisible () +" "+ isActive());
664665
if (!isEnabled () || !isVisible () || !isActive ()) return false;
666+
System.out.println("2");
665667
if (isFocusControl ()) return true;
668+
System.out.println("3");
666669
shell.setSavedFocus (null);
670+
System.out.println("4");
667671
/*
668672
* This code is intentionally commented.
669673
*
@@ -681,7 +685,12 @@ public boolean forceFocus () {
681685
// if (OS.GetFocus () != OS.SetFocus (handle)) return false;
682686
// OS.SetFocus (handle); // TODO
683687
if (isDisposed ()) return false;
688+
System.out.println("5");
689+
OS.SetFocus(handle);
690+
// return false;
691+
System.out.println("6");
684692
shell.setSavedFocus (this);
693+
System.out.println("7");
685694
return isFocusControl ();
686695
}
687696

0 commit comments

Comments
 (0)