mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-18 03:25:55 +00:00
ncmenu: check mouse clicks for presence #306
This commit is contained in:
parent
a325a6d4b0
commit
c6a3f93691
@ -479,8 +479,18 @@ const char* ncmenu_selected(const ncmenu* n, ncinput* ni){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
|
bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
|
||||||
fprintf(stderr, "KEY: %lc %u\n", nc->id, nc->id);
|
if(nc->id == NCKEY_RELEASE && ncplane_mouseevent_p(n->ncp, nc)){
|
||||||
if(n->unrolledsection < 0){
|
int y, x, dimy, dimx;
|
||||||
|
y = nc->y;
|
||||||
|
x = nc->x;
|
||||||
|
ncplane_dim_yx(n->ncp, &dimy, &dimx);
|
||||||
|
ncplane_translate(ncplane_stdplane(n->ncp), n->ncp, &y, &x);
|
||||||
|
if(y != (n->bottom ? dimy - 1 : 0)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ncmenu_rollup(n);
|
||||||
|
// FIXME unroll appropriate menu selection
|
||||||
|
}else if(n->unrolledsection < 0){ // all following need an unrolled section
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(nc->id == NCKEY_LEFT){
|
if(nc->id == NCKEY_LEFT){
|
||||||
@ -503,8 +513,6 @@ fprintf(stderr, "KEY: %lc %u\n", nc->id, nc->id);
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else if(nc->id == NCKEY_BUTTON1){
|
|
||||||
// FIXME did we clock on the menu? if so, unroll appropriately
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ int main(void){
|
|||||||
if(nc == NULL){
|
if(nc == NULL){
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
notcurses_mouse_enable(nc);
|
||||||
struct ncmenu_item demo_items[] = {
|
struct ncmenu_item demo_items[] = {
|
||||||
{ .desc = "Restart", .shortcut = { .id = 'r', .ctrl = true, }, },
|
{ .desc = "Restart", .shortcut = { .id = 'r', .ctrl = true, }, },
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user