Question
I'm developing a Tizen native application and need to implement long tap functionality on buttons. From what I can see in the button properties, this feature doesn't seem to be natively supported.
I found this implementation in a code snippet: https://developer.tizen.org/community/code-snippet/native-code-snippet/long-click-implementation. Is this still the only available option?
Also, I'm concerned about whether this implementation might interfere with regular click events. Has anyone successfully implemented this functionality without affecting normal click behavior?
Answer
Problem Understanding
The user wants to implement long tap functionality on buttons in a Tizen native application. The core challenges are:
- Native button objects don't directly support long tap events
- Need to ensure the solution doesn't interfere with regular click events
- Looking for the most efficient implementation method
Solution Methods
-
Gesture Layer Implementation:
- The most reliable approach is to use Tizen's gesture layer API
- Create a gesture layer over your button
- Implement long tap detection using gesture callbacks
-
Custom Timer Solution:
- Implement touch down/up event handlers
- Use a timer to detect long presses
- Clear the timer if the touch is released before the threshold
Code Examples
// Gesture layer implementation example
Evas_Object *gesture_layer = elm_gesture_layer_add(button);
elm_gesture_layer_attach(gesture_layer, button);
elm_gesture_layer_cb_set(gesture_layer, ELM_GESTURE_N_LONG_TAP,
ELM_GESTURE_STATE_MOVE, _long_tap_cb, data);
// Timer-based implementation example
static void _button_down(void *data, Evas *e, Evas_Object *obj, void *event_info) {
ecore_timer_add(1.0, _long_press_cb, data); // 1 second threshold
}
static void _button_up(void *data, Evas *e, Evas_Object *obj, void *event_info) {
ecore_timer_del(timer); // Cancel if released before threshold
}
Additional Tips
- The gesture layer method is generally more reliable and recommended
- Set appropriate time thresholds (typically 500ms-1000ms) for long tap detection
- Test thoroughly to ensure regular click events aren't affected
- Consider visual feedback (like button highlight) during long press