|
Lines 653-658
private int Invoke(int dispIdMember, long /*int*/ riid, int lcid, int dwFlags, l
Link Here
|
| 653 |
return COM.DISP_E_MEMBERNOTFOUND; |
653 |
return COM.DISP_E_MEMBERNOTFOUND; |
| 654 |
} |
654 |
} |
| 655 |
} |
655 |
} |
|
|
656 |
int OnClose() { |
| 657 |
getDisplay().asyncExec(new Runnable() { |
| 658 |
public void run() { |
| 659 |
System.out.println("onFocusOut"); |
| 660 |
fixCaret(); |
| 661 |
} |
| 662 |
}); |
| 663 |
return COM.S_OK; |
| 664 |
} |
| 656 |
private int OnControlInfoChanged() { |
665 |
private int OnControlInfoChanged() { |
| 657 |
long /*int*/[] ppvObject = new long /*int*/[1]; |
666 |
long /*int*/[] ppvObject = new long /*int*/[1]; |
| 658 |
if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) { |
667 |
if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) { |
|
Lines 666-671
private int OnControlInfoChanged() {
Link Here
|
| 666 |
return COM.S_OK; |
675 |
return COM.S_OK; |
| 667 |
} |
676 |
} |
| 668 |
protected int OnUIDeactivate(int fUndoable) { |
677 |
protected int OnUIDeactivate(int fUndoable) { |
|
|
678 |
/* |
| 679 |
* Bug in Windows. When IE7 loses focus and UIDeactivate() |
| 680 |
* is called, IE destroys the caret even though it is |
| 681 |
* no longer owned by IE. If focus has moved to a control |
| 682 |
* that shows a caret then the caret disappears. The fix |
| 683 |
* is to detect this case and restore the caret. |
| 684 |
*/ |
| 685 |
int threadId = OS.GetCurrentThreadId(); |
| 686 |
lpgui1 = new GUITHREADINFO(); |
| 687 |
lpgui1.cbSize = GUITHREADINFO.sizeof; |
| 688 |
OS.GetGUIThreadInfo(threadId, lpgui1); |
| 689 |
System.out.println("OnUIDeactivate caret=" + lpgui1.hwndCaret + " " + lpgui1.hwndFocus); |
| 669 |
return super.OnUIDeactivate(fUndoable); |
690 |
return super.OnUIDeactivate(fUndoable); |
| 670 |
} |
691 |
} |
| 671 |
void onFocusIn(Event e) { |
692 |
void onFocusIn(Event e) { |
|
Lines 697-723
void onFocusOut(Event e) {
Link Here
|
| 697 |
* our site. In such cases the site should not be UIDeactivated. |
718 |
* our site. In such cases the site should not be UIDeactivated. |
| 698 |
*/ |
719 |
*/ |
| 699 |
if (isFocusControl()) return; |
720 |
if (isFocusControl()) return; |
| 700 |
|
|
|
| 701 |
/* |
| 702 |
* Bug in Windows. When IE7 loses focus and UIDeactivate() |
| 703 |
* is called, IE destroys the caret even though it is |
| 704 |
* no longer owned by IE. If focus has moved to a control |
| 705 |
* that shows a caret then the caret disappears. The fix |
| 706 |
* is to detect this case and restore the caret. |
| 707 |
*/ |
| 708 |
int threadId = OS.GetCurrentThreadId(); |
| 709 |
GUITHREADINFO lpgui1 = new GUITHREADINFO(); |
| 710 |
lpgui1.cbSize = GUITHREADINFO.sizeof; |
| 711 |
OS.GetGUIThreadInfo(threadId, lpgui1); |
| 712 |
objIOleInPlaceObject.UIDeactivate(); |
721 |
objIOleInPlaceObject.UIDeactivate(); |
|
|
722 |
getDisplay().asyncExec(new Runnable() { |
| 723 |
public void run() { |
| 724 |
System.out.println("onFocusOut"); |
| 725 |
fixCaret(); |
| 726 |
} |
| 727 |
}); |
| 728 |
} |
| 729 |
GUITHREADINFO lpgui1; |
| 730 |
void fixCaret() { |
| 731 |
if (lpgui1 == null) return; |
| 713 |
if (SWT_RESTORECARET == 0) { |
732 |
if (SWT_RESTORECARET == 0) { |
| 714 |
SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true)); |
733 |
SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true)); |
| 715 |
} |
734 |
} |
| 716 |
if (lpgui1.hwndCaret != 0) { |
735 |
if (lpgui1.hwndCaret != 0) { |
|
|
736 |
int threadId = OS.GetCurrentThreadId(); |
| 717 |
GUITHREADINFO lpgui2 = new GUITHREADINFO(); |
737 |
GUITHREADINFO lpgui2 = new GUITHREADINFO(); |
| 718 |
lpgui2.cbSize = GUITHREADINFO.sizeof; |
738 |
lpgui2.cbSize = GUITHREADINFO.sizeof; |
| 719 |
OS.GetGUIThreadInfo(threadId, lpgui2); |
739 |
OS.GetGUIThreadInfo(threadId, lpgui2); |
| 720 |
if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) { |
740 |
if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) { |
|
|
741 |
System.out.println("FIXING 1=" + lpgui1.hwndCaret); |
| 721 |
/* |
742 |
/* |
| 722 |
* If the caret was not restored by SWT, put it back using |
743 |
* If the caret was not restored by SWT, put it back using |
| 723 |
* the information from GUITHREADINFO. Note that this will |
744 |
* the information from GUITHREADINFO. Note that this will |
|
Lines 733-740
void onFocusOut(Event e) {
Link Here
|
| 733 |
} |
754 |
} |
| 734 |
} |
755 |
} |
| 735 |
} else if (lpgui1.hwndFocus != 0 && lpgui1.hwndFocus == OS.GetFocus()) { |
756 |
} else if (lpgui1.hwndFocus != 0 && lpgui1.hwndFocus == OS.GetFocus()) { |
|
|
757 |
System.out.println("FIXING 2=" + lpgui1.hwndFocus); |
| 736 |
OS.SendMessage (lpgui1.hwndFocus, SWT_RESTORECARET, 0, 0); |
758 |
OS.SendMessage (lpgui1.hwndFocus, SWT_RESTORECARET, 0, 0); |
| 737 |
} |
759 |
} |
|
|
760 |
lpgui1 = null; |
| 738 |
} |
761 |
} |
| 739 |
private int OnFocus(int fGotFocus) { |
762 |
private int OnFocus(int fGotFocus) { |
| 740 |
return COM.S_OK; |
763 |
return COM.S_OK; |