How to use mouse wheel in Squeak / Morphic GUI

I am using the graphical user interface with Morphic / Squeak. Some items have a drag and drop function. While dragging, I want them to rotate these objects with the mouse.

the first problem is that using the mouse wheel completes the drag action and results in a drop (attempt). How can I suppress this - and at the same time run mouseWheelEvent?

second problem : how can I assign a Mousewheel event to my Morph? As mentioned above, this event only matters when you drag this Morph. (allowed)

+3
source share
2 answers

A message appears stating that in VM implementations that decide to support it, Squeak maps the mouse wheel to the Ctrl Up-Arrow and Ctrl-Down-Arrow keys . For example, 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, something you need to work inside Squeak. (If you use Polymorph extensions, there is a special event mouseWheel, but all they do is filter Ctrl-Up and Ctrl-Down and create a fake message MouseWheelEvent.)

See some code for handleEventin 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].
        ].

MouseWheelEvent MouseEvent, true isMove, . - , , .

+2

, - , , , , . , , , , , Xerox .

0

Source: https://habr.com/ru/post/1728832/


All Articles