Is it possible to invoke DrawMe() of an inactive tool?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
KuzKuz
Posts: 483
Joined: Mon Aug 19, 2013 5:12 pm
Location: Ukraine

Is it possible to invoke DrawMe() of an inactive tool?

Post by KuzKuz »

Hello, is it possible to call the DrawMe() function of an inactive tool in such a way that it can draw its graphics in the viewport?
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: Is it possible to invoke DrawMe() of an inactive tool?

Post by SimplSam »

There are a number of tools that already do this like TransformPoints:

Code: Select all

function LM_TransformPoints:DrawMe(moho, view)
...
    if (self.mode == self.selectMode and self.dragging) then
        LM_SelectPoints:DrawMe(moho, view)
        ...
    end
...
end
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
KuzKuz
Posts: 483
Joined: Mon Aug 19, 2013 5:12 pm
Location: Ukraine

Re: Is it possible to invoke DrawMe() of an inactive tool?

Post by KuzKuz »

Sorry, I might have asked the question incorrectly. I meant that the tool itself could invoke its DrawMe() even when it's not active. So that its graphics could be visible when any other tool is active, without the need to modify all tools.
User avatar
Lukas
Posts: 1297
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Is it possible to invoke DrawMe() of an inactive tool?

Post by Lukas »

KuzKuz wrote: Wed Jan 31, 2024 1:56 am[...] modify all tools.
This is how I've always achieved what I needed. But it would be nice to have it invoked on its own for sure...
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Is it possible to invoke DrawMe() of an inactive tool?

Post by hayasidist »

A thought --- DrawMe needs a MohoView. Is there any way that the "guts of the script" could provide the script's "IsEnabled" with a view that could be usable in its DrawMe() function???


I've had a go at this, and I can get IsEnabled to call DrawMe with a view object that I saved from the mainline run -- but right now I'm actually failing to get DrawMe to draw anything, even when in the tool's normal run-mode, so I've obviously screwed up somewhere in my DrawMe function... Sorry, but sorting that out is for another day - in the meantime, I'm logging this in the hope that it helps you guys make progress
Post Reply