Hello @chuanzhen,
Thank you for reaching out to us. I am not so sure what you are asking here for, but when I am reading a bit between the lines, I think the question is: "How to change the bubble help set by BFM_GETCURSORINFO
in a GeDialog
depending on the currently hovered gadget?" Please feel free to correct me when I misunderstood you.
In short, to display a different bubble help per element in a dialog, you must poll each element yourself. BFM_GETCURSORINFO
is just a global mouse-move event, it carries no mouse-over information. Note that there are also some gadgets which have a builtin custom bubble help as for example edit fields or BitmapButtonCustomGui
as mentioned by yourself. The pattern shown here works for all gadgets.
Cheers,
Ferdinand
Code:
"""Realizes a gadget dependent bubble help in a dialog for gadgets which do not support that on
their own.
This must be done by polling each gadget manually for a hit.
"""
import c4d
class MyDialog (c4d.gui.GeDialog):
"""Realizes a dialog with two buttons, both with their own bubble help.
"""
def CreateLayout(self) -> bool:
"""Adds the two buttons to the dialog.
"""
self.GroupBorderSpace(5, 5, 5, 5)
self.GroupSpace(5, 5)
# Other than edit fields, buttons do not have a builtin bubble help.
self.AddButton(1000, c4d.BFH_SCALEFIT, name = "Foo")
self.AddButton(1001, c4d.BFH_SCALEFIT, name = "Bar")
return True
def Message(self, msg: c4d.BaseContainer, result: any) -> bool:
"""Realizes the context sensitive bubble help.
"""
# BFM_GETCURSORINFO is being sent independently of gadgets, all we get in #msg, is the
# cursor position in global screen-space. A more modern and more aptly chosen name for this
# message would be OnMouseMove, because that is all what it does.
if msg.GetId() == c4d.BFM_GETCURSORINFO:
# Then we have to poll each element in our dialog manually for (x, y) being a point
# within their bounds with CheckDropArea (the methods are all not too well named here).
for gid, bubbleMsg in ((1000, "Foo Help"),
(1001, "Bar Help")):
if self.CheckDropArea(gid, msg, True, True):
result.SetId(c4d.BFM_GETCURSORINFO)
result.SetString(c4d.RESULT_BUBBLEHELP, bubbleMsg)
break
return c4d.gui.GeDialog.Message(self, msg, result)
if __name__ == "__main__":
dlg = MyDialog()
dlg.Open(c4d.DLG_TYPE_ASYNC, 0, -1, -1, 200, 200)