diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp index 8848ed086..e383e25b3 100644 --- a/src/app/ui/tabs.cpp +++ b/src/app/ui/tabs.cpp @@ -62,6 +62,8 @@ Tabs::Tabs(TabsDelegate* delegate) , m_dropNewTab(nullptr) , m_dropNewIndex(-1) { + enableFlags(CTRL_RIGHT_CLICK); + setDoubleBuffered(true); initTheme(); @@ -1003,7 +1005,11 @@ void Tabs::updateDragCopyCursor(ui::Message* msg) TabPtr tab = (m_isDragging ? m_dragTab: m_hot); bool oldDragCopy = m_dragCopy; - m_dragCopy = ((msg->ctrlPressed() || msg->altPressed()) && + m_dragCopy = (( +#if !defined __APPLE__ + msg->ctrlPressed() || +#endif + msg->altPressed()) && (tab && m_delegate && m_delegate->canCloneTab(this, tab->view))); if (oldDragCopy != m_dragCopy) { diff --git a/src/ui/base.h b/src/ui/base.h index 5d18d40f6..1df93d596 100644 --- a/src/ui/base.h +++ b/src/ui/base.h @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2001-2013, 2015 David Capello +// Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -47,6 +47,7 @@ namespace ui { INITIALIZED = 0x00000400, // The widget was already initialized by a theme. DIRTY = 0x00000800, // The widget (or one child) is dirty (update_region != empty). HAS_TEXT = 0x00001000, // The widget has text (at least setText() was called one time). + CTRL_RIGHT_CLICK = 0x00002000, // The widget should transform Ctrl+click to right-click on OS X. PROPERTIES_MASK = 0x0000ffff, HORIZONTAL = 0x00010000, diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index c382b097f..4c71b3c43 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -28,7 +28,7 @@ namespace ui { -Entry::Entry(std::size_t maxsize, const char *format, ...) +Entry::Entry(std::size_t maxsize, const char* format, ...) : Widget(kEntryWidget) , m_timer(500, this) , m_maxsize(maxsize) @@ -42,9 +42,10 @@ Entry::Entry(std::size_t maxsize, const char *format, ...) , m_recent_focused(false) , m_lock_selection(false) { - char buf[4096]; + enableFlags(CTRL_RIGHT_CLICK); // formatted string + char buf[4096]; if (format) { va_list ap; va_start(ap, format); diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 1317f68d5..697eed78b 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -1458,11 +1458,24 @@ Message* Manager::newMouseMessage( const gfx::Point& wheelDelta, bool preciseWheel) { +#ifdef __APPLE__ + // Convert Ctrl+left click -> right-click + if (widget && + widget->isVisible() && + widget->isEnabled() && + widget->hasFlags(CTRL_RIGHT_CLICK) && + (modifiers & kKeyCtrlModifier) && + (buttons == kButtonLeft)) { + modifiers = KeyModifiers(int(modifiers) & ~int(kKeyCtrlModifier)); + buttons = kButtonRight; + } +#endif + Message* msg = new MouseMessage( type, pointerType, buttons, modifiers, mousePos, wheelDelta, preciseWheel); - if (widget != NULL) + if (widget) msg->addRecipient(widget); return msg;