*/
typedef void (*remote_input_key_event_cb)(void *user_data);
+/**
+ * @platform
+ * @brief Called when the position of the cursor in an associated text field changes.
+ * @since_tizen 7.0
+ * @remarks This callback will be called after remote_input_focus_in_cb().
+ * @param[in] cursor_pos The cursor position
+ * @param[in] user_data User data to be passed to the callback function
+ * @pre The callback can be registered using remote_input_cursor_position_updated_callback_set() function.
+ * @see remote_input_cursor_position_updated_callback_set()
+ * @see remote_input_cursor_position_updated_callback_unset()
+ */
+typedef void (*remote_input_cursor_position_updated_cb)(int cursor_pos, void *user_data);
+
/**
* @platform
* @brief Creates a remote input handle.
*/
int remote_input_key_event_callback_unset(remote_input_h remote_handle);
+/**
+ * @platform
+ * @brief Requests to set cursor position.
+ * @since_tizen 7.0
+ * @remarks This function must be used if an associated text field has focus.
+ * Otherwise, #REMOTE_INPUT_ERROR_OPERATION_FAILED will be returned.
+ * @param[in] remote_handle The remote input handle
+ * @param[in] cursor_pos The cursor position
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #REMOTE_INPUT_ERROR_OPERATION_FAILED Operation failure
+ */
+int remote_input_set_cursor_position(remote_input_h remote_handle, int cursor_pos);
+
+/**
+ * @platform
+ * @brief Sets a callback function to be called when the cursor position is changed.
+ * @since_tizen 7.0
+ * @param[in] remote_handle The remote input handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data User data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_cursor_position_updated_callback_unset()
+ */
+int remote_input_cursor_position_updated_callback_set(remote_input_h remote_handle, remote_input_cursor_position_updated_cb callback, void *user_data);
+
+/**
+ * @platform
+ * @brief Unsets the callback function.
+ * @since_tizen 7.0
+ * @param[in] remote_handle The remote input handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_cursor_position_updated_callback_set()
+ */
+int remote_input_cursor_position_updated_callback_unset(remote_input_h remote_handle);
+
/**
* @}
void *resource_changed_cb_user_data;
remote_input_key_event_cb key_event_cb;
void *key_event_cb_user_data;
+ remote_input_cursor_position_updated_cb cursor_position_updated_cb;
+ void *cursor_position_updated_cb_user_data;
};
#endif /* __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ */
remote_handle->key_event_cb(remote_handle->key_event_cb_user_data);
}
}
+
+static void _cursor_position_updated_cb(void *user_data, int cursor_pos)
+{
+ remote_input_h remote_handle = (remote_input_h)user_data;
+
+ if (remote_handle == NULL) {
+ LOGE("remote handle is not available");
+ return;
+ }
+
+ if (remote_handle->cursor_position_updated_cb) {
+ remote_handle->cursor_position_updated_cb(cursor_pos, remote_handle->text_updated_cb_user_data);
+ }
+}
//LCOV_EXCL_STOP
EXPORT_API int remote_input_create(remote_input_h *remote_handle)
remote_handle->key_event_cb = NULL;
remote_handle->key_event_cb_user_data = NULL;
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_set_cursor_position(remote_input_h remote_handle, int cursor_pos)
+{
+ if (!remote_handle || cursor_pos < 0) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (remote_control_set_cursor_position(remote_handle->remote_client, cursor_pos) != REMOTE_CONTROL_ERROR_NONE) {
+ LOGE("REMOTE_INPUT_ERROR_OPERATION_FAILED");
+ return REMOTE_INPUT_ERROR_OPERATION_FAILED;
+ }
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_cursor_position_updated_callback_set(remote_input_h remote_handle, remote_input_cursor_position_updated_cb callback, void *user_data)
+{
+ if (!remote_handle || !remote_handle->remote_client || !callback) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ remote_control_cursor_position_updated_callback_set(remote_handle->remote_client, _cursor_position_updated_cb, (void *)remote_handle);
+ remote_handle->cursor_position_updated_cb = callback;
+ remote_handle->cursor_position_updated_cb_user_data = user_data;
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_cursor_position_updated_callback_unset(remote_input_h remote_handle)
+{
+ if (!remote_handle || !remote_handle->remote_client) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ remote_control_cursor_position_updated_callback_unset(remote_handle->remote_client);
+ remote_handle->cursor_position_updated_cb = NULL;
+ remote_handle->cursor_position_updated_cb_user_data = NULL;
+
return REMOTE_INPUT_ERROR_NONE;
}
\ No newline at end of file