Skip to content

set_content_update_callbackSetContentUpdateCallbackSetContentUpdateCallbackset_content_update_callbackT_set_content_update_callback🔗

Short description🔗

set_content_update_callbackSetContentUpdateCallbackSetContentUpdateCallbackset_content_update_callbackT_set_content_update_callback — Sets the callback for content updates in buffer window.

Signature🔗

set_content_update_callback( window WindowHandle, pointer CallbackFunction, pointer CallbackContext )void SetContentUpdateCallback( const HTuple& WindowHandle, const HTuple& CallbackFunction, const HTuple& CallbackContext )static void HOperatorSet.SetContentUpdateCallback( HTuple windowHandle, HTuple callbackFunction, HTuple callbackContext )def set_content_update_callback( window_handle: HHandle, callback_function: int, callback_context: Union[int, HHandle] ) -> None

Herror T_set_content_update_callback( const Htuple WindowHandle, const Htuple CallbackFunction, const Htuple CallbackContext )

void HWindow::SetContentUpdateCallback( void* CallbackFunction, const HTuple& CallbackContext ) const

void HWindow::SetContentUpdateCallback( void* CallbackFunction, void* CallbackContext ) const

void HWindow.SetContentUpdateCallback( IntPtr callbackFunction, HTuple callbackContext )

void HWindow.SetContentUpdateCallback( IntPtr callbackFunction, IntPtr callbackContext )

Description🔗

set_content_update_callbackSetContentUpdateCallback sets a callback CallbackFunctioncallbackFunctioncallback_function, which is called whenever the contents of the buffer window WindowHandlewindowHandlewindow_handle change. The parameter CallbackContextcallbackContextcallback_context is always passed to the callback.

The type of CallbackFunctioncallbackFunctioncallback_function is: Herror callback(void *context)

On Windows systems, the __stdcall calling convention is used: Herror __stdcall callback(void *context)

The callback function must not call a HALCON operator. Doing so is undefined behavior. It is advised to perform only computationally inexpensive tasks in the callback, e.g., setting a flag or triggering an asynchronous operation.

In combination with the operators send_mouse_down_eventSendMouseDownEvent, send_mouse_up_eventSendMouseUpEvent, and send_mouse_double_click_eventSendMouseDoubleClickEvent, set_content_update_callbackSetContentUpdateCallback can be used to create a buffer based control for a GUI Toolkit (such as Qt), where the control passes mouse events to the buffer, while the buffer notifies the control on changes by calling the function CallbackFunctioncallbackFunctioncallback_function. The control then can obtain the contents of the buffer with dump_window_imageDumpWindowImage and display them.

Attention🔗

set_content_update_callbackSetContentUpdateCallback depends on the library libcanvas, which might not be available on embedded systems.

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🔗

WindowHandlewindowHandlewindow_handle (input_control) window → (handle)HTuple (HHandle)HWindow, HTuple (IntPtr)HHandleHtuple (handle)

Window handle.

CallbackFunctioncallbackFunctioncallback_function (input_control) pointer → (integer)HTuple (Hlong)HTuple (IntPtr)intHtuple (Hlong)

Callback for content updates.

CallbackContextcallbackContextcallback_context (input_control) pointer → (integer / handle)HTuple (Hlong / HHandle)HTuple (IntPtr / IntPtr)Union[int, HHandle]Htuple (Hlong / handle)

Parameter to CallbackFunction.

Result🔗

If the window exists and is a buffer window, set_content_update_callbackSetContentUpdateCallback returns 2 (H_MSG_TRUE).

Combinations with other operators🔗

Combinations

See also

flush_bufferFlushBuffer

Module🔗

Foundation