MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onProcessMessage

Method onProcessMessage

src/ui/menu.cpp:365–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365bool MenuBox::onProcessMessage(Message* msg)
366{
367 Menu* menu = MenuBox::getMenu();
368
369 switch (msg->type()) {
370
371 case kMouseMoveMessage:
372 if (!get_base(this)->was_clicked)
373 break;
374
375 // Fall through
376
377 case kMouseDownMessage:
378 if (menu) {
379 if (get_base(this)->is_processing)
380 break;
381
382 gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
383
384 // Here we catch the filtered messages (menu-bar or the
385 // popuped menu-box) to detect if the user press outside of
386 // the widget
387 if (msg->type() == kMouseDownMessage && m_base != NULL) {
388 Widget* picked = manager()->pick(mousePos);
389
390 // If one of these conditions are accomplished we have to
391 // close all menus (back to menu-bar or close the popuped
392 // menubox), this is the place where we control if...
393 if (picked == NULL || // If the button was clicked nowhere
394 picked == this || // If the button was clicked in this menubox
395 // The picked widget isn't from the same tree of menus
396 (get_base_menubox(picked) != this ||
397 (this->type() == kMenuBarWidget &&
398 picked->type() == kMenuWidget))) {
399
400 // The user click outside all the menu-box/menu-items, close all
401 menu->closeAll();
402 return true;
403 }
404 }
405
406 // Get the widget below the mouse cursor
407 Widget* picked = menu->pick(mousePos);
408 if (picked) {
409 if ((picked->type() == kMenuItemWidget) &&
410 !(picked->hasFlags(DISABLED))) {
411 MenuItem* pickedItem = static_cast<MenuItem*>(picked);
412
413 // If the picked menu-item is not highlighted...
414 if (!pickedItem->isHighlighted()) {
415 // In menu-bar always open the submenu, in other popup-menus
416 // open the submenu only if the user does click
417 bool open_submenu =
418 (this->type() == kMenuBarWidget) ||
419 (msg->type() == kMouseDownMessage);
420
421 menu->highlightItem(pickedItem, false, open_submenu, false);
422 }

Callers

nothing calls this directly

Calls 15

get_baseFunction · 0.85
get_base_menuboxFunction · 0.85
check_for_letterFunction · 0.85
scancode_to_asciiFunction · 0.85
find_previtemFunction · 0.85
find_nextitemFunction · 0.85
guiscaleFunction · 0.85
display_wFunction · 0.85
display_hFunction · 0.85
pickMethod · 0.80
closeAllMethod · 0.80
isHighlightedMethod · 0.80

Tested by

no test coverage detected