MouseMove listener

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

MouseMove listener

Post by RR88 » Fri Oct 01, 2021 5:10 pm

Hello.

I want to get the mouse-position within a document. How can I do this? I tried this:

Code: Select all

include('scripts/EAction.js');

function Test(guiAction) {
    EAction.call(this, guiAction);
}

Test.prototype = new EAction();

Test.prototype.beginEvent = function() {
    EAction.prototype.beginEvent.call(this);
};

Test.prototype.mouseMoveEvent = function(event) {
    qDebug(event.getScreenPosition());
}

Test.init = function(basePath) {
    var action = new RGuiAction('Test', RMainWindowQt.getMainWindow());
    action.setRequiresDocument(true);
    action.setGroupSortOrder(100000);
    action.setSortOrder(0);
    action.setWidgetNames(['MiscModifyMenu']);
};
mouseMoveEvent will not be called.
Arch Linux, QCad 3.22.0 Prof.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: MouseMove listener

Post by andrew » Fri Oct 01, 2021 5:21 pm

Your menu does not actually call a script (or do anything at all).

Add this to your Test.init:

Code: Select all

action.setScriptFile(basePath + "/Test.js");
To learn how to do these things properly, please browse the examples at:
https://github.com/qcad/qcad/tree/master/scripts

For example the point drawing tool at:
https://github.com/qcad/qcad/tree/maste ... nt/Point1P

RR88
Full Member
Posts: 51
Joined: Sun Apr 29, 2018 7:04 am
Location: Leinefelde

Re: MouseMove listener

Post by RR88 » Fri Oct 01, 2021 5:25 pm

Thanks. I knew I had forgotten something. :D
Arch Linux, QCad 3.22.0 Prof.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”