Problem encountered when check double click in Message() Use MSG_EDIT
-
Hi,
In the tag plugin, i use MSG_EDIT in Message() to detect the double-click behavior of the mouse, and then execute some commands. However, when create tag, MSG_EDIT is also used. I tried using gui.GetInputState (c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_DOUBLECLICK,bc) obtains specific information to distinguish between label create tag and double-click behavior, but bc no double click information is obtained.
code:def Message(self, node: GeListNode, type: int, data: object) -> bool: if type == c4d.MSG_EDIT: c4d.CallCommand(200000084) # Rectangle Selection bc = c4d.BaseContainer() gui.GetInputState(c4d.BFM_INPUT_MOUSE,c4d.BFM_INPUT_DOUBLECLICK,bc) if bc[c4d.BFM_INPUT_DOUBLECLICK] : print("double") return True return True
How to distinguish between these two behaviors
Thanks for any help! -
Hi @chuanzhen,
the TagData plugins don't receive MSG_EDIT message on single click (when user selects the tag in the Object Manager). If you receive the MSG_EDIT, it means the tag is being edited, i.e. the user has double clicked on it. Technically, it can be caused by any event that ends up in editing the tag (i.e. not only by double clicking on it in OB). This is basically why you receive this message on creation. On practice, I haven't seen in the code places, other than double clicking, that send MSG_EDIT to our tagdata objects, so it's kind of safe to assume that receiving this message is equal to having a double click.
If you like to distinguish the MSG_EDIT that's sent on creation from the double click case, you'd need to handle this bookkeeping yourself, e.g. having some system that tracks the existence of tags in the scene and filters out the on-creation MSG_EDIT misfire.
By the way, there's no need to check for c4d.BFM_INPUT_DOUBLECLICK, as at the time tagdata plugin receives the message the input event is already consumed, hence you won't get this information at that point.
Cheers,
Ilia -
@i_mazlov Thanks