void NativeTextfieldWin::OnMouseMove(UINT keys, const gfx::Point& point) { SetContainsMouse(true); // Clamp the selection to the visible text so the user can't drag to select // the "phantom newline". In theory we could achieve this by clipping the X // coordinate, but in practice the edit seems to behave nondeterministically // with similar sequences of clipped input coordinates fed to it. Maybe it's // reading the mouse cursor position directly? // // This solution has a minor visual flaw, however: if there's a visible // cursor at the edge of the text (only true when there's no selection), // dragging the mouse around outside that edge repaints the cursor on every // WM_MOUSEMOVE instead of allowing it to blink normally. To fix this, we // special-case this exact case and discard the WM_MOUSEMOVE messages instead // of passing them along. // // But even this solution has a flaw! (Argh.) In the case where the user // has a selection that starts at the edge of the edit, and proceeds to the // middle of the edit, and the user is dragging back past the start edge to // remove the selection, there's a redraw problem where the change between // having the last few bits of text still selected and having nothing // selected can be slow to repaint (which feels noticeably strange). This // occurs if you only let the edit receive a single WM_MOUSEMOVE past the // edge of the text. I think on each WM_MOUSEMOVE the edit is repainting its // previous state, then updating its internal variables to the new state but // not repainting. To fix this, we allow one more WM_MOUSEMOVE through after // the selection has supposedly been shrunk to nothing; this makes the edit // redraw the selection quickly so it feels smooth. CHARRANGE selection; GetSel(selection); const bool possibly_can_discard_mousemove = (selection.cpMin==selection.cpMax) && (((selection.cpMin==0) && (ClipXCoordToVisibleText(point.x(), false)>point.x())) || ((selection.cpMin==GetTextLength()) && (ClipXCoordToVisibleText(point.x(), false)<point.x()))); if(!can_discard_mousemove_ || !possibly_can_discard_mousemove) { can_discard_mousemove_ = possibly_can_discard_mousemove; ScopedFreeze freeze(this, GetTextObjectModel()); OnBeforePossibleChange(); // Force the Y coordinate to the center of the clip rect. The edit // behaves strangely when the cursor is dragged vertically: if the cursor // is in the middle of the text, drags inside the clip rect do nothing, // and drags outside the clip rect act as if the cursor jumped to the // left edge of the text. When the cursor is at the right edge, drags of // just a few pixels vertically end up selecting the "phantom newline"... // sometimes. RECT r; GetRect(&r); DefWindowProc(WM_MOUSEMOVE, keys, MAKELPARAM(point.x(), (r.bottom-r.top)/2)); OnAfterPossibleChange(true); } }
static void initMouseEvent(WebInputEvent::Type t, WebMouseEvent::Button b, const gfx::Point& pos, WebMouseEvent* e) { e->type = t; e->button = b; e->modifiers = 0; e->x = pos.x(); e->y = pos.y(); e->globalX = pos.x(); e->globalY = pos.y(); e->timeStampSeconds = getCurrentEventTimeSec(); e->clickCount = clickCount; }
bool SingleSplitView::IsPointInDivider(const gfx::Point& p) { if(GetChildViewCount() < 2) { return false; } if(!GetChildViewAt(0)->IsVisible() || !GetChildViewAt(1)->IsVisible()) { return false; } int divider_relative_offset; if(is_horizontal_) { divider_relative_offset = p.x() - GetChildViewAt(base::IsRTL() ? 1 : 0)->width(); } else { divider_relative_offset = p.y() - GetChildViewAt(0)->height(); } return (divider_relative_offset>=0 && divider_relative_offset<kDividerSize); }
int DialogClientView::NonClientHitTest(const gfx::Point& point) { if(size_box_bounds_.Contains(point.x()-x(), point.y()-y())) { return HTBOTTOMRIGHT; } return ClientView::NonClientHitTest(point); }
void NativeTextfieldWin::OnLButtonUp(UINT keys, const gfx::Point& point) { ScopedFreeze freeze(this, GetTextObjectModel()); OnBeforePossibleChange(); DefWindowProc(WM_LBUTTONUP, keys, MAKELPARAM(ClipXCoordToVisibleText(point.x(), false), point.y())); OnAfterPossibleChange(true); }
void DraggedTabView::MoveTo(const gfx::Point& screen_point) { int x; if(base::i18n::IsRTL()) { // On RTL locales, a dragged tab (when it is not attached to a tab strip) // is rendered using a right-to-left orientation so we should calculate the // window position differently. gfx::Size ps = GetPreferredSize(); x = screen_point.x() + ScaleValue(mouse_tab_offset_.x() - ps.width()); } else { x = screen_point.x() - ScaleValue(mouse_tab_offset_.x()); } int y = screen_point.y() - ScaleValue(mouse_tab_offset_.y()); // TODO(beng): make this cross-platform int show_flags = container_->IsVisible() ? SWP_NOZORDER : SWP_SHOWWINDOW; SetWindowPos(container_->GetNativeView(), HWND_TOP, x, y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | show_flags); }
void NativeTextfieldWin::OnLButtonDblClk(UINT keys, const gfx::Point& point) { // Save the double click info for later triple-click detection. tracking_double_click_ = true; double_click_point_ = point; double_click_time_ = GetCurrentMessage()->time; ScopedFreeze freeze(this, GetTextObjectModel()); OnBeforePossibleChange(); DefWindowProc(WM_LBUTTONDBLCLK, keys, MAKELPARAM(ClipXCoordToVisibleText(point.x(), false), point.y())); OnAfterPossibleChange(true); }
void GanttViewMenuController::ShowContextMenuForView( view::View* source, const gfx::Point& p, bool is_mouse_gesture) { scoped_ptr<view::Menu> menu(view::Menu::Create(this, view::Menu::TOPLEFT, source->GetWidget()->GetNativeView())); menu->AppendMenuItem(GANTTVIEWCONTEXTMENUCOMMAND_EDIT, L"指针模式", view::Menu::RADIO); menu->AppendMenuItem(GANTTVIEWCONTEXTMENUCOMMAND_CREATE_BAR, L"创建节点模式", view::Menu::RADIO); menu->AppendMenuItem(GANTTVIEWCONTEXTMENUCOMMAND_CREATE_LINK, L"创建链接模式", view::Menu::RADIO); menu->RunMenuAt(p.x(), p.y()); }
void NativeTextfieldWin::OnLButtonDown(UINT keys, const gfx::Point& point) { // Check for triple click, then reset tracker. Should be safe to subtract // double_click_time_ from the current message's time even if the timer has // wrapped in between. const bool is_triple_click = tracking_double_click_ && IsDoubleClick(double_click_point_.ToPOINT(), point.ToPOINT(), GetCurrentMessage()->time-double_click_time_); tracking_double_click_ = false; ScopedFreeze freeze(this, GetTextObjectModel()); OnBeforePossibleChange(); DefWindowProc(WM_LBUTTONDOWN, keys, MAKELPARAM(ClipXCoordToVisibleText(point.x(), is_triple_click), point.y())); OnAfterPossibleChange(true); }