如何在 Squeak / Morphic GUI 中使用鼠标滚轮

发布于 2024-08-18 07:54:53 字数 252 浏览 9 评论 0原文

我正在使用 Morphic / Squeak 实现图形用户界面。有些项目具有拖拽功能。删除功能。拖动时,我希望能够使用鼠标滚轮旋转这些项目。

第一个问题是使用鼠标滚轮结束拖动操作并导致放置(尝试)。我怎样才能抑制它 - 并同时触发 mouseWheelEvent ?

第二个问题:如何为我的 Morph 分配鼠标滚轮事件?如上所述,此事件仅在拖动此变形时才相关。(已解决)

I am implementing a graphical user interface with Morphic / Squeak. Some of the items have drag & drop functionality. While dragging, I want to be able to rotate these items with the mousewheel.

The first problem is that using the mousewheel ends the drag-action and leads to a drop (attempt). How can I suppress that - and fire the mouseWheelEvent at the same time?

The second problem: How can I assign a mousewheel-event to my Morph? As mentioned above, this event only is relevant while dragging this Morph. (solved)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵你的手,一向走下去 2024-08-25 07:54:53

似乎在选择支持它的 VM 实现上,Squeak 将鼠标滚轮映射到 Ctrl 向上箭头Ctrl-向下箭头 键事件。例如,在 Win32 上 sqWin32Window.c

if( WM_MOUSEWHEEL == message || g_WM_MOUSEWHEEL == message ) {
    /* Record mouse wheel msgs as CTRL-Up/Down */
    short zDelta = (short) HIWORD(wParam);
    if(inputSemaphoreIndex) {
        sqKeyboardEvent *evt = (sqKeyboardEvent*) sqNextEventPut();
        evt->type = EventTypeKeyboard;
        evt->timeStamp = lastMessage->time;
        evt->charCode = (zDelta > 0) ? 30 : 31;
        evt->pressCode = EventKeyChar;
        evt->modifiers = CtrlKeyBit;
        evt->utf32Code = 0;
        evt->reserved1 = 0;
    } else {
        buttonState = 64;
        if (zDelta < 0) {
            recordVirtualKey(message,VK_DOWN,lParam);
        } else {
            recordVirtualKey(message,VK_UP,lParam);
        }
    }
    return 1;
}

这就是您在 Squeak 中需要使用的内容。 (如果您使用的是 Polymorph 扩展,则有一个特殊的 mouseWheel 事件,但它们所做的只是过滤 Ctrl-Up 和 Ctrl-Down 并生成“假”MouseWheelEvent< /code> 消息。)

查看 HandMorphhandleEvent 的一些代码:

evt isMouse ifTrue:[
    self sendListenEvent: evt to: self mouseListeners.
    lastMouseEvent _ evt].

    "Check for pending drag or double click operations."
    mouseClickState ifNotNil:[
        (mouseClickState handleEvent: evt from: self) ifFalse:[
        "Possibly dispatched #click: or something and will not re-establish otherwise"
        ^self mouseOverHandler processMouseOver: lastMouseEvent]].

        evt isMove ifTrue:[
            self position: evt position.
            self sendMouseEvent: evt.
        ] ifFalse:[
            "Issue a synthetic move event if we're not at the position of the event"
            (evt position = self position) ifFalse:[self moveToEvent: evt].
            "Drop submorphs on button events"
            (self hasSubmorphs) 
                ifTrue:[self dropMorphs: evt]
                ifFalse:[self sendMouseEvent: evt].
        ].

Polymorph MouseWheelEvent 是 MouseEvent 的子类,它不返回 true 到 isMove,因此你会得到一个掉落。如果你想让它起作用,你必须在这里改变一些东西。

Appears that on VM implementations that have chosen to support it, Squeak maps the mouse wheel to Ctrl Up-Arrow and Ctrl-Down-Arrow key events. For instance, on Win32 in sqWin32Window.c:

if( WM_MOUSEWHEEL == message || g_WM_MOUSEWHEEL == message ) {
    /* Record mouse wheel msgs as CTRL-Up/Down */
    short zDelta = (short) HIWORD(wParam);
    if(inputSemaphoreIndex) {
        sqKeyboardEvent *evt = (sqKeyboardEvent*) sqNextEventPut();
        evt->type = EventTypeKeyboard;
        evt->timeStamp = lastMessage->time;
        evt->charCode = (zDelta > 0) ? 30 : 31;
        evt->pressCode = EventKeyChar;
        evt->modifiers = CtrlKeyBit;
        evt->utf32Code = 0;
        evt->reserved1 = 0;
    } else {
        buttonState = 64;
        if (zDelta < 0) {
            recordVirtualKey(message,VK_DOWN,lParam);
        } else {
            recordVirtualKey(message,VK_UP,lParam);
        }
    }
    return 1;
}

So that's pretty much what you've got to work with inside Squeak. (If you're using the Polymorph extensions, there is a special mouseWheel event, but all they're doing is filtering Ctrl-Up and Ctrl-Down and generating a "fake" MouseWheelEvent message.)

Looking at a bit of code for handleEvent in HandMorph:

evt isMouse ifTrue:[
    self sendListenEvent: evt to: self mouseListeners.
    lastMouseEvent _ evt].

    "Check for pending drag or double click operations."
    mouseClickState ifNotNil:[
        (mouseClickState handleEvent: evt from: self) ifFalse:[
        "Possibly dispatched #click: or something and will not re-establish otherwise"
        ^self mouseOverHandler processMouseOver: lastMouseEvent]].

        evt isMove ifTrue:[
            self position: evt position.
            self sendMouseEvent: evt.
        ] ifFalse:[
            "Issue a synthetic move event if we're not at the position of the event"
            (evt position = self position) ifFalse:[self moveToEvent: evt].
            "Drop submorphs on button events"
            (self hasSubmorphs) 
                ifTrue:[self dropMorphs: evt]
                ifFalse:[self sendMouseEvent: evt].
        ].

The Polymorph MouseWheelEvent is a subclass of MouseEvent that doesn't return true to isMove, hence you get a drop. You'll have to change something here if you want this to work.

甜心小果奶 2024-08-25 07:54:53

最好的选择是找到一个能够执行您想要的操作的变形,然后浏览它的方法以了解它是如何做到的。话虽如此,我还没有遇到过任何支持滚轮特定功能的鼠标,当然原始的施乐鼠标也没有这样的功能。

Your best bet is to find a morph that does something like what you want and then browse its methods to see how it does it. Having said that, I haven't come across any that support wheel-specific functions, and of course the original Xerox mouse had no such feature.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文