2525import org .eclipse .swt .internal .xhtml .Element ;
2626import org .eclipse .swt .internal .xhtml .HTMLEvent ;
2727import org .eclipse .swt .internal .xhtml .document ;
28+ import org .eclipse .swt .internal .xhtml .window ;
2829
2930/**
3031 * Instances of this class are selectable user interface
@@ -226,6 +227,11 @@ void createHandle () {
226227 if (textCSSName != null ) {
227228 textHandle .className = textCSSName ;
228229 }
230+ handle .onfocus = new RunnableCompatibility () {
231+ public void run () {
232+ textHandle .focus ();
233+ }
234+ };
229235 handle .appendChild (textHandle );
230236
231237 //setTabStops (tabs = 8);
@@ -326,6 +332,13 @@ public void run() {
326332 };
327333 textHandle .onblur = new RunnableCompatibility () {
328334 public void run () {
335+ String className = handle .className ;
336+ int idx = className .indexOf ("text-focus" );
337+ if ( idx != -1 ){
338+ handle .className = className .substring (0 , idx ) +
339+ className .substring (idx + "text-focus" .length ());
340+ }
341+ System .out .println ("class name " + handle .className );
329342 Event e = new Event ();
330343 e .type = SWT .FocusOut ;
331344 e .item = Text .this ;
@@ -334,6 +347,21 @@ public void run() {
334347 toReturn (e .doit );
335348 }
336349 };
350+ textHandle .onfocus = new RunnableCompatibility () {
351+ public void run () {
352+ String className = handle .className ;
353+ if (className .indexOf ("text-focus" ) == -1 ){
354+ handle .className = className + " text-focus" ;
355+ }
356+ System .out .println ("class name " + handle .className );
357+ Event e = new Event ();
358+ e .type = SWT .FocusIn ;
359+ e .item = Text .this ;
360+ e .widget = Text .this ;
361+ sendEvent (e );
362+ toReturn (e .doit );
363+ }
364+ };
337365}
338366
339367private char getInputCharacter (int keyCode , boolean shiftKey , boolean capsLockStatus ) {
@@ -2791,4 +2819,11 @@ void enableWidget (boolean enabled) {
27912819 OS .updateCSSClass (handle , "text-disabled" , !enabled );
27922820}
27932821
2822+ public boolean forceFocus () {
2823+ boolean ret = super .forceFocus ();
2824+ this .textHandle .focus ();
2825+ return ret ;
2826+ }
2827+
2828+
27942829}
0 commit comments