Element User Data
PBElementGetUserDataInt
Function: Get the integer associated with the element.
Syntax (C/C++)
int64_t PBElementGetUserDataInt(PBElementRef element);
Syntax (Python)
ElementGetUserDataInt(element) -> (userData)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[out] userData (int64_t
): The integer value stored in the element.
Discussion
This will work even after the element has been destroyed.
See Also
PBElementGetUserDataPtr
Function: Get the pointer associated with the element.
Syntax (C/C++)
void *_Nullable PBElementGetUserDataPtr(PBElementRef element);
Syntax (Python)
ElementGetUserDataPtr(element) -> (userData)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[out] userData (opaque pointer): The pointer value stored in the element.
Discussion
This will work even after the element has been destroyed.
See Also
PBElementGetWindowUserDataInt
Function: Get the integer associated with the window in which the element is contained.
Syntax (C/C++)
int64_t PBElementGetWindowUserDataInt(PBElementRef element);
Syntax (Python)
ElementGetWindowUserDataInt(element) -> (userData)
Parameters and Return Values
[in] element (referenced PBElement): The element in the window.
[out] userData (int64_t
): The integer value stored in the window.
See Also
PBElementGetWindowUserDataPtr
Function: Get the pointer associated with the window in which the element is contained.
Syntax (C/C++)
void *_Nullable PBElementGetWindowUserDataPtr(PBElementRef element);
Syntax (Python)
ElementGetWindowUserDataPtr(element) -> (userData)
Parameters and Return Values
[in] element (referenced PBElement): The element in the window.
[out] userData (opaque pointer): The pointer value stored in the window.
Discussion
It is common for applications to store various state of the window here. This function provides convenient access to the value from any element in the window.
See Also
PBElementSetUserDataInt
Function: Modify the integer associated with the element.
Syntax (C/C++)
void PBElementSetUserDataInt(PBElementRef element, int64_t userData);
Syntax (Python)
ElementSetUserDataInt(element, userData)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[in] userData (int64_t
): The new integer to store.
Discussion
Applications can freely assign both an integer and pointer (see PBElementSetUserDataPtr) for each element to allow the application to identify it, together called the element's user data. The function modifies the integer value.
This will work even after the element has been destroyed.
Example (C/C++)
intptr_t FieldMessage(PBElement *element, PBMessage *message) {
if (message->type == PBMsg_VALUE_CHANGED) {
int64_t value = PBElementGetUserDataInt(element);
PBLogInfo("Field %lld changed.", (long long) value);
}
return 0;
}
for (int i = 1; i <= 5; i++) {
PBInputField *field = PBInputFieldCreateSingleLine(
parent, 0, 0, NULL);
PBElementSetUserDataInt((PBElement *) field, i);
PBElementSetUserMessageHandler((PBElement *) field,
PBElementMessageHandler_Make(FieldMessage));
}
See Also
- PBElementGetUserDataInt
- PBElementGetWindowUserDataInt
- PBElementSetUserDataPtr
- PBElementSetUserMessageHandler
PBElementSetUserDataPtr
Function: Modify the pointer associated with the element.
Syntax (C/C++)
void PBElementSetUserDataPtr(PBElementRef element, void *_Nullable userData);
Syntax (Python)
ElementSetUserDataPtr(element, userData)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[in] userData (opaque pointer): The new pointer to store.
Discussion
Applications can freely assign both an integer (see PBElementSetUserDataInt) and pointer for each element to allow the application to identify it, together called the element's user data. The function modifies the pointer value.
See PBElementSetUserDataInt for an example of using the user data.
If this call replaces a pointer set using PBElementSetUserDataPtrWithOwnership, then the old value will be freed using PBHeapFree.
This will work even after the element has been destroyed.
See Also
- PBElementGetUserDataPtr
- PBElementGetWindowUserDataPtr
- PBElementSetUserDataInt
- PBElementSetUserMessageHandler
PBElementSetUserDataPtrWithOwnership
Function: Modify the pointer associated with the element and mark it for automatic deallocation.
Syntax (C/C++)
void PBElementSetUserDataPtrWithOwnership(PBElementRef element,
void *_Nullable userData);
Syntax (Python)
ElementSetUserDataPtrWithOwnership(element, userData)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[in] userData (opaque pointer): The new pointer to store. This must have been allocated using PBHeapAllocate or similar.
Discussion
The system will automatically free the pointer passed to this function when the element is destroyed or if it replaced by another call to a SetUserDataPtr function.
This will work even after the element has been destroyed.
See Also
PBElementSetUserMessageHandler
Function: Set the user message handler of the element.
Syntax (C/C++)
void PBElementSetUserMessageHandler(PBElementRef element,
PBElementMessageHandler handler);
Syntax (Python)
ElementSetUserMessageHandler(element, handler)
Parameters and Return Values
[in] element (referenced PBElement): The element.
[in] handler (PBElementMessageHandler): The new user message handler.
Discussion
See PBElementMessage for a description of how an element's message handlers are used.