MsgRouting AwtScrollbar::HandleEvent(MSG *msg, BOOL synthetic) { if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) { if (IsFocusable() && AwtComponent::sm_focusOwner != GetHWnd()) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = GetTarget(env); env->CallStaticVoidMethod (AwtKeyboardFocusManager::keyboardFocusManagerCls, AwtKeyboardFocusManager::heavyweightButtonDownMID, target, ((jlong)msg->time) & 0xFFFFFFFF); env->DeleteLocalRef(target); AwtSetFocus(); } // Left button press was already routed to default window // procedure in the WmMouseDown above. Propagating synthetic // press seems like a bad idea as internal message loop // doesn't know how to unwrap synthetic release. delete msg; return mrConsume; } else { return AwtComponent::HandleEvent(msg, synthetic); } }
MsgRouting AwtCanvas::HandleEvent(MSG *msg, BOOL synthetic) { if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) { /* * Fix for BugTraq ID 4041703: keyDown not being invoked. * Give the focus to a Canvas or Panel if it doesn't have heavyweight * subcomponents so that they will behave the same way as on Solaris * providing a possibility of giving keyboard focus to an empty Applet. * Since ScrollPane doesn't receive focus on mouse press on Solaris, * HandleEvent() is overriden there to do nothing with focus. */ if (AwtComponent::sm_focusOwner != GetHWnd() && ::GetWindow(GetHWnd(), GW_CHILD) == NULL) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject target = GetTarget(env); env->CallStaticVoidMethod (AwtKeyboardFocusManager::keyboardFocusManagerCls, AwtKeyboardFocusManager::heavyweightButtonDownMID, target, ((jlong)msg->time) & 0xFFFFFFFF); env->DeleteLocalRef(target); AwtSetFocus(); } } return AwtComponent::HandleEvent(msg, synthetic); }
// Work around a windows bug descrbed in KB article Q73839. Reset // focus on scrollbars to update focus indicator. The article advises // to disable/enable the scrollbar, but simply resetting the focus is // sufficient. void AwtScrollbar::UpdateFocusIndicator() { if (IsFocusable()) { m_ignoreFocusEvents = TRUE; ::SetFocus(NULL); AwtSetFocus(); m_ignoreFocusEvents = FALSE; } }