@@ -52,8 +52,8 @@ public class Text extends Scrollable {
52
52
boolean doubleClick , ignoreModify , ignoreVerify , ignoreCharacter ;
53
53
54
54
boolean keyDownOK ;
55
-
56
55
Element textHandle ;
56
+ private String textValue ;
57
57
58
58
int lineHeight ;
59
59
@@ -197,6 +197,7 @@ void createHandle () {
197
197
textHandle .type = "text" ;
198
198
}
199
199
}
200
+ textValue = "" ;
200
201
String textCSSName = null ;
201
202
if (OS .isIE ) {
202
203
textCSSName = "text-ie-default" ;
@@ -315,26 +316,33 @@ public void run() {
315
316
String s = verifyText (txt , 0 , 0 , e );
316
317
if (s == null ) {
317
318
toReturn (false );
319
+ return ;
318
320
} else if (hooks (SWT .Modify )) {
319
- Event ev = new Event ();
320
- ev .type = SWT .Modify ;
321
- ev .widget = Text .this ;
322
- ev .display = display ;
323
- ev .time = display .getLastEventTime ();
324
- sendEvent (ev );
325
- toReturn (ev .doit );
321
+ if (textValue != textHandle .value ) {
322
+ textValue = textHandle .value ;
323
+ Event ev = new Event ();
324
+ ev .type = SWT .Modify ;
325
+ ev .widget = Text .this ;
326
+ ev .display = display ;
327
+ ev .time = display .getLastEventTime ();
328
+ sendEvent (ev );
329
+ toReturn (ev .doit );
330
+ }
326
331
}
327
332
}
328
333
}
329
334
keyDownOK = this .isReturned ();
330
335
if (!verifyHooked || hooks (SWT .KeyDown )) {
331
336
Event ev = new Event ();
332
- ev .type = SWT .Modify ;
333
- ev .widget = Text .this ;
334
- ev .display = display ;
335
- ev .time = display .getLastEventTime ();
336
- sendEvent (ev );
337
- toReturn (ev .doit );
337
+ if (textValue != textHandle .value ) {
338
+ textValue = textHandle .value ;
339
+ ev .type = SWT .Modify ;
340
+ ev .widget = Text .this ;
341
+ ev .display = display ;
342
+ ev .time = display .getLastEventTime ();
343
+ sendEvent (ev );
344
+ toReturn (ev .doit );
345
+ }
338
346
339
347
HTMLEventWrapper e = new HTMLEventWrapper (getEvent ());
340
348
HTMLEvent evt = (HTMLEvent ) e .event ;
@@ -438,24 +446,25 @@ public void run() {
438
446
}
439
447
String newText = textHandle .value ;
440
448
if (newText != null ) {
441
- //String oldText = newText;
442
449
newText = verifyText (newText , 0 , 0 , null );
443
450
if (newText == null ) {
444
451
toReturn (true );
445
452
return ;
446
453
}
447
- //if (!newText.equals (oldText)) {
454
+ if (textValue != textHandle .value ) {
455
+ textValue = textHandle .value ;
448
456
Event e = new Event ();
449
457
e .type = SWT .Modify ;
450
458
e .item = Text .this ;
451
459
e .widget = Text .this ;
452
460
sendEvent (e );
453
461
toReturn (e .doit );
454
- // }
462
+ }
455
463
}
456
464
}
457
465
};
458
466
Clazz .addEvent (textHandle , "keyup" , hModifyKeyUp );
467
+ Clazz .addEvent (textHandle , "change" , hModifyKeyUp );
459
468
460
469
hModifyBlur = new RunnableCompatibility () {
461
470
public void run () {
@@ -629,6 +638,10 @@ public void append (String string) {
629
638
OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
630
639
*/
631
640
textHandle .value += string ;
641
+ if (string .length () > 0 ) {
642
+ textValue = textHandle .value ;
643
+ sendEvent (SWT .Modify );
644
+ }
632
645
}
633
646
634
647
static int checkStyle (int style ) {
@@ -1632,10 +1645,16 @@ public void insert (String string) {
1632
1645
ignoreCharacter = false;
1633
1646
*/
1634
1647
insertTextString (textHandle , string );
1648
+ /*
1635
1649
if ((style & SWT.MULTI) != 0) {
1636
1650
sendEvent (SWT.Modify);
1637
1651
// widget could be disposed at this point
1638
1652
}
1653
+ */
1654
+ if (textValue != textHandle .value ) {
1655
+ textValue = textHandle .value ;
1656
+ sendEvent (SWT .Modify );
1657
+ }
1639
1658
}
1640
1659
1641
1660
/**
@@ -1760,6 +1779,7 @@ protected void releaseHandle() {
1760
1779
hModifyFocus = null ;
1761
1780
}
1762
1781
if (hModifyKeyUp != null ) {
1782
+ Clazz .removeEvent (textHandle , "change" , hModifyKeyUp );
1763
1783
Clazz .removeEvent (textHandle , "keyup" , hModifyKeyUp );
1764
1784
hModifyKeyUp = null ;
1765
1785
}
@@ -2385,10 +2405,16 @@ public void setText (String string) {
2385
2405
* notify the application that the text has changed.
2386
2406
* The fix is to send the event.
2387
2407
*/
2388
- //if ((style & SWT.MULTI) != 0) {
2408
+ /*
2409
+ if ((style & SWT.MULTI) != 0) {
2389
2410
sendEvent (SWT.Modify);
2390
2411
// widget could be disposed at this point
2391
- //}
2412
+ }
2413
+ */
2414
+ if (textValue != string ) {
2415
+ textValue = string ;
2416
+ sendEvent (SWT .Modify );
2417
+ }
2392
2418
}
2393
2419
2394
2420
/**
0 commit comments