set_drawing_object_callbackT_set_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callback (算子)

名称

set_drawing_object_callbackT_set_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callback — 向绘图对象添加回调函数。

签名

set_drawing_object_callback( : : DrawHandle, DrawObjectEvent, CallbackFunction : )

Herror T_set_drawing_object_callback(const Htuple DrawHandle, const Htuple DrawObjectEvent, const Htuple CallbackFunction)

void SetDrawingObjectCallback(const HTuple& DrawHandle, const HTuple& DrawObjectEvent, const HTuple& CallbackFunction)

void HDrawingObject::SetDrawingObjectCallback(const HTuple& DrawObjectEvent, const HTuple& CallbackFunction) const

void HDrawingObject::SetDrawingObjectCallback(const HString& DrawObjectEvent, void* CallbackFunction) const

void HDrawingObject::SetDrawingObjectCallback(const char* DrawObjectEvent, void* CallbackFunction) const

void HDrawingObject::SetDrawingObjectCallback(const wchar_t* DrawObjectEvent, void* CallbackFunction) const   ( Windows only)

static void HOperatorSet.SetDrawingObjectCallback(HTuple drawHandle, HTuple drawObjectEvent, HTuple callbackFunction)

void HDrawingObject.SetDrawingObjectCallback(HTuple drawObjectEvent, HTuple callbackFunction)

void HDrawingObject.SetDrawingObjectCallback(string drawObjectEvent, IntPtr callbackFunction)

def set_drawing_object_callback(draw_handle: HHandle, draw_object_event: MaybeSequence[str], callback_function: MaybeSequence[int]) -> None

描述

set_drawing_object_callbackset_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callback adds the callback function CallbackFunctionCallbackFunctionCallbackFunctionCallbackFunctioncallbackFunctioncallback_function to be called on the event(s) defined in DrawObjectEventDrawObjectEventDrawObjectEventDrawObjectEventdrawObjectEventdraw_object_event to the drawing object DrawHandleDrawHandleDrawHandleDrawHandledrawHandledraw_handle. An event is an action, i.e., a user interaction with the mouse or a call to a HALCON operator, e.g., attach_drawing_object_to_windowattach_drawing_object_to_windowAttachDrawingObjectToWindowAttachDrawingObjectToWindowAttachDrawingObjectToWindowattach_drawing_object_to_window), that changes the current state of a given drawing object. The operator set_drawing_object_callbackset_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callback allows to define how to react to those events.

The following predefined events are available:

'on_attach'"on_attach""on_attach""on_attach""on_attach""on_attach"

The corresponding callback will be called right after the object has been attached to the HALCON window and is ready for interaction.

'on_detach'"on_detach""on_detach""on_detach""on_detach""on_detach"

The corresponding callback will be called right after the object has been detached from the window and is no longer available for interaction.

'on_drag'"on_drag""on_drag""on_drag""on_drag""on_drag"

The corresponding callback will be called right after the object has been dragged with mouse interaction.

'on_resize'"on_resize""on_resize""on_resize""on_resize""on_resize"

The corresponding callback will be called right after the object has been resized with mouse interaction.

'on_select'"on_select""on_select""on_select""on_select""on_select"

The corresponding callback will be called right after the object has been selected with mouse interaction.

It is possible to specify a particular callback for each desired event. Then the input parameters DrawObjectEventDrawObjectEventDrawObjectEventDrawObjectEventdrawObjectEventdraw_object_event and CallbackFunctionCallbackFunctionCallbackFunctionCallbackFunctioncallbackFunctioncallback_function must have the same length. It is also possible to use the same callback for different events. Then DrawObjectEventDrawObjectEventDrawObjectEventDrawObjectEventdrawObjectEventdraw_object_event has an arbitrary length and CallbackFunctionCallbackFunctionCallbackFunctionCallbackFunctioncallbackFunctioncallback_function contains one single value.

The callback is an integer of long type containing a pointer to a C function with the following signature:

Herror HDrawObjCallback(long DrawHandle, long WindowHandle, char *type)

On Windows systems, the __stdcall naming convention is used:

Herror (__stdcall HDrawObjCallback)(long DrawHandle, long WindowHandle, char* type)

The first parameter of the callback function contains the handle to the draw object that generated the event, the second one contains the handle of the window where the interaction took place. Finally, the third parameter indicates which event occurred.

注意

No graphical operator should be called within the callback, like for example disp_objdisp_objDispObjDispObjDispObjdisp_obj, for otherwise a deadlock may occur.

执行信息

参数

DrawHandleDrawHandleDrawHandleDrawHandledrawHandledraw_handle (输入控制)  drawing_object HDrawingObject, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

绘图对象的句柄。

DrawObjectEventDrawObjectEventDrawObjectEventDrawObjectEventdrawObjectEventdraw_object_event (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Events to be captured.

建议值: 'on_resize'"on_resize""on_resize""on_resize""on_resize""on_resize", 'on_drag'"on_drag""on_drag""on_drag""on_drag""on_drag", 'on_attach'"on_attach""on_attach""on_attach""on_attach""on_attach", 'on_detach'"on_detach""on_detach""on_detach""on_detach""on_detach", 'on_select'"on_select""on_select""on_select""on_select""on_select"

CallbackFunctionCallbackFunctionCallbackFunctionCallbackFunctioncallbackFunctioncallback_function (输入控制)  pointer(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Callback functions.

结果

set_drawing_object_callbackset_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callback returns 2 ( H_MSG_TRUE) , if DrawHandleDrawHandleDrawHandleDrawHandledrawHandledraw_handle is valid.否则将抛出异常。

可能的前趋

attach_drawing_object_to_windowattach_drawing_object_to_windowAttachDrawingObjectToWindowAttachDrawingObjectToWindowAttachDrawingObjectToWindowattach_drawing_object_to_window

可能的后继

close_windowclose_windowCloseWindowCloseWindowCloseWindowclose_window, clear_drawing_objectclear_drawing_objectClearDrawingObjectClearDrawingObjectClearDrawingObjectclear_drawing_object, detach_drawing_object_from_windowdetach_drawing_object_from_windowDetachDrawingObjectFromWindowDetachDrawingObjectFromWindowDetachDrawingObjectFromWindowdetach_drawing_object_from_window, get_drawing_object_iconicget_drawing_object_iconicGetDrawingObjectIconicGetDrawingObjectIconicGetDrawingObjectIconicget_drawing_object_iconic, get_drawing_object_paramsget_drawing_object_paramsGetDrawingObjectParamsGetDrawingObjectParamsGetDrawingObjectParamsget_drawing_object_params

另见

create_drawing_object_rectangle1create_drawing_object_rectangle1CreateDrawingObjectRectangle1CreateDrawingObjectRectangle1CreateDrawingObjectRectangle1create_drawing_object_rectangle1, attach_drawing_object_to_windowattach_drawing_object_to_windowAttachDrawingObjectToWindowAttachDrawingObjectToWindowAttachDrawingObjectToWindowattach_drawing_object_to_window, detach_drawing_object_from_windowdetach_drawing_object_from_windowDetachDrawingObjectFromWindowDetachDrawingObjectFromWindowDetachDrawingObjectFromWindowdetach_drawing_object_from_window

模块

基础