Hello,
I have a Rect
called lastRect
(which is a rect for an object field), and I want to perform and operation if the user (for example) left click on it while holding the Ctrl
key.
I’m not sure how to go about doing that, I tried this:
if (lastRect != null && lastRect.Contains(Event.current.mousePosition)) {
if (Event.current.control)
if (Event.current.button == 0)
{
isObjectField = !isObjectField;
}
}
It didn’t seem to work, it gave strange results. For example, if I hold Ctrl and do a left click, the boolean toggles, then if I just hold Ctrl without a LMB, it toggles too!
I think that’s not the way to detect input in this case.
I tried caching the current event, and using the local version instead, didn’t seem to change much. I also tried using the event (Event.current.Use()
) when the boolean toggles, didn’t do much too (inspector went crazy).
Any ideas?
Thanks!