Skip to content

set_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callbackT_set_drawing_object_callback🔗

Short description🔗

set_drawing_object_callbackSetDrawingObjectCallbackSetDrawingObjectCallbackset_drawing_object_callbackT_set_drawing_object_callback — Add a callback function to a drawing object.

Signature🔗

set_drawing_object_callback( drawing_object DrawHandle, string DrawObjectEvent, pointer CallbackFunction )void SetDrawingObjectCallback( const HTuple& DrawHandle, const HTuple& DrawObjectEvent, const HTuple& CallbackFunction )static void HOperatorSet.SetDrawingObjectCallback( HTuple drawHandle, HTuple drawObjectEvent, HTuple callbackFunction )def set_drawing_object_callback( draw_handle: HHandle, draw_object_event: MaybeSequence[str], callback_function: MaybeSequence[int] ) -> None

Herror T_set_drawing_object_callback( 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)

void HDrawingObject.SetDrawingObjectCallback( HTuple drawObjectEvent, HTuple callbackFunction )

void HDrawingObject.SetDrawingObjectCallback( string drawObjectEvent, IntPtr callbackFunction )

Description🔗

set_drawing_object_callbackSetDrawingObjectCallback adds the callback function CallbackFunctioncallbackFunctioncallback_function to be called on the event(s) defined in DrawObjectEventdrawObjectEventdraw_object_event to the drawing object DrawHandledrawHandledraw_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_windowAttachDrawingObjectToWindow), that changes the current state of a given drawing object. The operator set_drawing_object_callbackSetDrawingObjectCallback allows to define how to react to those events.

The following predefined events are available:

  • '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" 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" The corresponding callback will be called right after the object has been dragged with mouse interaction.

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

  • '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 DrawObjectEventdrawObjectEventdraw_object_event and CallbackFunctioncallbackFunctioncallback_function must have the same length. It is also possible to use the same callback for different events. Then DrawObjectEventdrawObjectEventdraw_object_event has an arbitrary length and CallbackFunctioncallbackFunctioncallback_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 HDrawObjectCallback(Hphandle DrawHandle, Hphandle WindowHandle, char* type)

On Windows systems, the __stdcall naming convention is used:

Herror __stdcall HDrawObjectCallback(Hphandle DrawHandle, Hphandle 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.

Attention🔗

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

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

DrawHandledrawHandledraw_handle (input_control) drawing_object → (handle)HTuple (HHandle)HDrawingObject, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the drawing object.

DrawObjectEventdrawObjectEventdraw_object_event (input_control) string(-array) → (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)

Events to be captured.

Suggested values: 'on_resize', 'on_drag', 'on_attach', 'on_detach', 'on_select'"on_resize", "on_drag", "on_attach", "on_detach", "on_select"

CallbackFunctioncallbackFunctioncallback_function (input_control) pointer(-array) → (integer)HTuple (Hlong)HTuple (IntPtr)MaybeSequence[int]Htuple (Hlong)

Callback functions.

Result🔗

set_drawing_object_callbackSetDrawingObjectCallback returns 2 (H_MSG_TRUE), if DrawHandledrawHandledraw_handle is valid. Otherwise an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

attach_drawing_object_to_windowAttachDrawingObjectToWindow

Possible successors

close_windowCloseWindow, clear_drawing_objectClearDrawingObject, detach_drawing_object_from_windowDetachDrawingObjectFromWindow, get_drawing_object_iconicGetDrawingObjectIconic, get_drawing_object_paramsGetDrawingObjectParams

See also

create_drawing_object_rectangle1CreateDrawingObjectRectangle1, attach_drawing_object_to_windowAttachDrawingObjectToWindow, detach_drawing_object_from_windowDetachDrawingObjectFromWindow

Module🔗

Foundation