I'm trying to implement a button action that displays text on my ScrollLayer when the Select button is pressed. I used:
scroll_layer_set_click_config_onto_window(scrollLayer, window);
to set the BUTTON_UP and BUTTON_DOWN callback functions automatically (to scroll). So then I want to set a BUTTON_SELECT callback function. I wrote these two functions:
//Performs an action whenver the 'select' button is pressed
void select_click_handler(ClickRecognizerRef recognizer, void *ctx) {
text_layer_set_text(textLayer, "You pressed select");
}
//Links the select button to a function, select_click_handler
void click_config_provider(void *ctx) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
}
And in my initializer I have:
void init() {
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
window_set_click_config_provider(window, click_config_provider);
window_stack_push(window,true);
}
When I run this, it compiles and installs on the watch just fine, however, when I hit the select button, nothing happens. When I comment out scroll_layer_set_click_config_onto_window(scrollLayer, window);
it works like it is supposed to.
Is there a way to override the select button callback without having to comment out the above line?
Thanks in advance!
I found a simple workaround using scroll_layer_set_callbacks()
function here:
http://forums.getpebble.com/discussion/11432/scroll-layer-set-callbacks