InterfaceObjectConfigurable.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * InterfaceBuilder.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "InterfaceObjectConfigurable.h"
  12. #include "../CGameInfo.h"
  13. #include "../CPlayerInterface.h"
  14. #include "../gui/CGuiHandler.h"
  15. #include "../gui/ShortcutHandler.h"
  16. #include "../gui/Shortcut.h"
  17. #include "../widgets/CComponent.h"
  18. #include "../widgets/Buttons.h"
  19. #include "../widgets/MiscWidgets.h"
  20. #include "../widgets/ObjectLists.h"
  21. #include "../widgets/TextControls.h"
  22. #include "../windows/GUIClasses.h"
  23. #include "../windows/InfoWindows.h"
  24. #include "../../lib/CGeneralTextHandler.h"
  25. #include "../../lib/filesystem/ResourceID.h"
  26. InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset):
  27. InterfaceObjectConfigurable(used, offset)
  28. {
  29. build(config);
  30. }
  31. InterfaceObjectConfigurable::InterfaceObjectConfigurable(int used, Point offset):
  32. CIntObject(used, offset)
  33. {
  34. REGISTER_BUILDER("picture", &InterfaceObjectConfigurable::buildPicture);
  35. REGISTER_BUILDER("image", &InterfaceObjectConfigurable::buildImage);
  36. REGISTER_BUILDER("texture", &InterfaceObjectConfigurable::buildTexture);
  37. REGISTER_BUILDER("animation", &InterfaceObjectConfigurable::buildAnimation);
  38. REGISTER_BUILDER("label", &InterfaceObjectConfigurable::buildLabel);
  39. REGISTER_BUILDER("toggleGroup", &InterfaceObjectConfigurable::buildToggleGroup);
  40. REGISTER_BUILDER("toggleButton", &InterfaceObjectConfigurable::buildToggleButton);
  41. REGISTER_BUILDER("button", &InterfaceObjectConfigurable::buildButton);
  42. REGISTER_BUILDER("labelGroup", &InterfaceObjectConfigurable::buildLabelGroup);
  43. REGISTER_BUILDER("slider", &InterfaceObjectConfigurable::buildSlider);
  44. REGISTER_BUILDER("layout", &InterfaceObjectConfigurable::buildLayout);
  45. }
  46. void InterfaceObjectConfigurable::registerBuilder(const std::string & type, BuilderFunction f)
  47. {
  48. builders[type] = f;
  49. }
  50. void InterfaceObjectConfigurable::addCallback(const std::string & callbackName, std::function<void(int)> callback)
  51. {
  52. callbacks[callbackName] = callback;
  53. }
  54. void InterfaceObjectConfigurable::deleteWidget(const std::string & name)
  55. {
  56. auto iter = widgets.find(name);
  57. if(iter != widgets.end())
  58. widgets.erase(iter);
  59. }
  60. void InterfaceObjectConfigurable::loadCustomBuilders(const JsonNode & config)
  61. {
  62. for(auto & item : config.Struct())
  63. {
  64. std::string typeName = item.first;
  65. JsonNode baseConfig = item.second;
  66. auto const & functor = [this, baseConfig](const JsonNode & widgetConfig) -> std::shared_ptr<CIntObject>
  67. {
  68. JsonNode actualConfig = widgetConfig;
  69. JsonUtils::mergeCopy(actualConfig, baseConfig);
  70. return this->buildWidget(actualConfig);
  71. };
  72. registerBuilder(typeName, functor);
  73. }
  74. }
  75. void InterfaceObjectConfigurable::build(const JsonNode &config)
  76. {
  77. OBJ_CONSTRUCTION;
  78. logGlobal->debug("Building configurable interface object");
  79. auto * items = &config;
  80. if(config.getType() == JsonNode::JsonType::DATA_STRUCT)
  81. {
  82. if (!config["library"].isNull())
  83. {
  84. const JsonNode library(ResourceID(config["library"].String()));
  85. loadCustomBuilders(library);
  86. }
  87. loadCustomBuilders(config["customTypes"]);
  88. for(auto & item : config["variables"].Struct())
  89. {
  90. logGlobal->debug("Read variable named %s", item.first);
  91. variables[item.first] = item.second;
  92. }
  93. items = &config["items"];
  94. }
  95. for(const auto & item : items->Vector())
  96. addWidget(item["name"].String(), buildWidget(item));
  97. }
  98. void InterfaceObjectConfigurable::addConditional(const std::string & name, bool active)
  99. {
  100. conditionals[name] = active;
  101. }
  102. void InterfaceObjectConfigurable::addWidget(const std::string & namePreferred, std::shared_ptr<CIntObject> widget)
  103. {
  104. static const std::string unnamedObjectPrefix = "__widget_";
  105. std::string nameActual;
  106. if (widgets.count(namePreferred) == 0)
  107. nameActual = namePreferred;
  108. else
  109. logGlobal->error("Duplicated widget name: '%s'", namePreferred);
  110. if (nameActual.empty())
  111. nameActual = unnamedObjectPrefix + std::to_string(unnamedObjectId++);
  112. logGlobal->debug("Building widget with name %s", nameActual);
  113. widgets[nameActual] = widget;
  114. }
  115. std::string InterfaceObjectConfigurable::readText(const JsonNode & config) const
  116. {
  117. if(config.isNull())
  118. return "";
  119. std::string s = config.String();
  120. logGlobal->debug("Reading text from translations by key: %s", s);
  121. return CGI->generaltexth->translate(s);
  122. }
  123. Point InterfaceObjectConfigurable::readPosition(const JsonNode & config) const
  124. {
  125. Point p;
  126. logGlobal->debug("Reading point");
  127. p.x = config["x"].Integer();
  128. p.y = config["y"].Integer();
  129. return p;
  130. }
  131. Rect InterfaceObjectConfigurable::readRect(const JsonNode & config) const
  132. {
  133. Rect p;
  134. logGlobal->debug("Reading rect");
  135. p.x = config["x"].Integer();
  136. p.y = config["y"].Integer();
  137. p.w = config["w"].Integer();
  138. p.h = config["h"].Integer();
  139. return p;
  140. }
  141. ETextAlignment InterfaceObjectConfigurable::readTextAlignment(const JsonNode & config) const
  142. {
  143. logGlobal->debug("Reading text alignment");
  144. if(!config.isNull())
  145. {
  146. if(config.String() == "center")
  147. return ETextAlignment::CENTER;
  148. if(config.String() == "left")
  149. return ETextAlignment::TOPLEFT;
  150. if(config.String() == "right")
  151. return ETextAlignment::BOTTOMRIGHT;
  152. }
  153. logGlobal->debug("Uknown text alignment attribute");
  154. return ETextAlignment::CENTER;
  155. }
  156. SDL_Color InterfaceObjectConfigurable::readColor(const JsonNode & config) const
  157. {
  158. logGlobal->debug("Reading color");
  159. if(!config.isNull())
  160. {
  161. if(config.String() == "yellow")
  162. return Colors::YELLOW;
  163. if(config.String() == "white")
  164. return Colors::WHITE;
  165. if(config.String() == "gold")
  166. return Colors::METALLIC_GOLD;
  167. if(config.String() == "green")
  168. return Colors::GREEN;
  169. if(config.String() == "orange")
  170. return Colors::ORANGE;
  171. if(config.String() == "bright-yellow")
  172. return Colors::BRIGHT_YELLOW;
  173. }
  174. logGlobal->debug("Uknown color attribute");
  175. return Colors::DEFAULT_KEY_COLOR;
  176. }
  177. EFonts InterfaceObjectConfigurable::readFont(const JsonNode & config) const
  178. {
  179. logGlobal->debug("Reading font");
  180. if(!config.isNull())
  181. {
  182. if(config.String() == "big")
  183. return EFonts::FONT_BIG;
  184. if(config.String() == "medium")
  185. return EFonts::FONT_MEDIUM;
  186. if(config.String() == "small")
  187. return EFonts::FONT_SMALL;
  188. if(config.String() == "tiny")
  189. return EFonts::FONT_TINY;
  190. if(config.String() == "calisto")
  191. return EFonts::FONT_CALLI;
  192. }
  193. logGlobal->debug("Uknown font attribute");
  194. return EFonts::FONT_TIMES;
  195. }
  196. std::pair<std::string, std::string> InterfaceObjectConfigurable::readHintText(const JsonNode & config) const
  197. {
  198. logGlobal->debug("Reading hint text");
  199. std::pair<std::string, std::string> result;
  200. if(!config.isNull())
  201. {
  202. if(config.getType() == JsonNode::JsonType::DATA_STRUCT)
  203. {
  204. result.first = readText(config["hover"]);
  205. result.second = readText(config["help"]);
  206. return result;
  207. }
  208. if(config.getType() == JsonNode::JsonType::DATA_STRING)
  209. {
  210. logGlobal->debug("Reading hint text (help) from generaltext handler:%sd", config.String());
  211. result.first = CGI->generaltexth->translate( config.String(), "hover");
  212. result.second = CGI->generaltexth->translate( config.String(), "help");
  213. }
  214. }
  215. return result;
  216. }
  217. EShortcut InterfaceObjectConfigurable::readHotkey(const JsonNode & config) const
  218. {
  219. logGlobal->debug("Reading hotkey");
  220. if(config.getType() != JsonNode::JsonType::DATA_STRING)
  221. {
  222. logGlobal->error("Invalid hotket format in interface configuration! Expected string!", config.String());
  223. return EShortcut::NONE;
  224. }
  225. EShortcut result = GH.shortcutsHandler().findShortcut(config.String());
  226. if (result == EShortcut::NONE)
  227. logGlobal->error("Invalid hotkey '%s' in interface configuration!", config.String());
  228. return result;;
  229. }
  230. std::shared_ptr<CPicture> InterfaceObjectConfigurable::buildPicture(const JsonNode & config) const
  231. {
  232. logGlobal->debug("Building widget CPicture");
  233. auto image = config["image"].String();
  234. auto position = readPosition(config["position"]);
  235. auto pic = std::make_shared<CPicture>(image, position.x, position.y);
  236. if(!config["visible"].isNull())
  237. pic->visible = config["visible"].Bool();
  238. if ( config["playerColored"].Bool() && LOCPLINT)
  239. pic->colorize(LOCPLINT->playerID);
  240. return pic;
  241. }
  242. std::shared_ptr<CLabel> InterfaceObjectConfigurable::buildLabel(const JsonNode & config) const
  243. {
  244. logGlobal->debug("Building widget CLabel");
  245. auto font = readFont(config["font"]);
  246. auto alignment = readTextAlignment(config["alignment"]);
  247. auto color = readColor(config["color"]);
  248. auto text = readText(config["text"]);
  249. auto position = readPosition(config["position"]);
  250. return std::make_shared<CLabel>(position.x, position.y, font, alignment, color, text);
  251. }
  252. std::shared_ptr<CToggleGroup> InterfaceObjectConfigurable::buildToggleGroup(const JsonNode & config) const
  253. {
  254. logGlobal->debug("Building widget CToggleGroup");
  255. auto position = readPosition(config["position"]);
  256. auto group = std::make_shared<CToggleGroup>(0);
  257. group->pos += position;
  258. if(!config["items"].isNull())
  259. {
  260. OBJ_CONSTRUCTION_TARGETED(group.get());
  261. int itemIdx = -1;
  262. for(const auto & item : config["items"].Vector())
  263. {
  264. itemIdx = item["index"].isNull() ? itemIdx + 1 : item["index"].Integer();
  265. auto newToggle = std::dynamic_pointer_cast<CToggleButton>(buildWidget(item));
  266. group->addToggle(itemIdx, newToggle);
  267. }
  268. }
  269. if(!config["selected"].isNull())
  270. group->setSelected(config["selected"].Integer());
  271. if(!config["callback"].isNull())
  272. group->addCallback(callbacks.at(config["callback"].String()));
  273. return group;
  274. }
  275. std::shared_ptr<CToggleButton> InterfaceObjectConfigurable::buildToggleButton(const JsonNode & config) const
  276. {
  277. logGlobal->debug("Building widget CToggleButton");
  278. auto position = readPosition(config["position"]);
  279. auto image = config["image"].String();
  280. auto help = readHintText(config["help"]);
  281. auto button = std::make_shared<CToggleButton>(position, image, help);
  282. if(!config["items"].isNull())
  283. {
  284. for(const auto & item : config["items"].Vector())
  285. {
  286. button->addOverlay(buildWidget(item));
  287. }
  288. }
  289. if(!config["selected"].isNull())
  290. button->setSelected(config["selected"].Bool());
  291. if(!config["imageOrder"].isNull())
  292. {
  293. auto imgOrder = config["imageOrder"].Vector();
  294. assert(imgOrder.size() >= 4);
  295. button->setImageOrder(imgOrder[0].Integer(), imgOrder[1].Integer(), imgOrder[2].Integer(), imgOrder[3].Integer());
  296. }
  297. loadToggleButtonCallback(button, config["callback"]);
  298. return button;
  299. }
  300. std::shared_ptr<CButton> InterfaceObjectConfigurable::buildButton(const JsonNode & config) const
  301. {
  302. logGlobal->debug("Building widget CButton");
  303. auto position = readPosition(config["position"]);
  304. auto image = config["image"].String();
  305. auto help = readHintText(config["help"]);
  306. auto button = std::make_shared<CButton>(position, image, help);
  307. if(!config["items"].isNull())
  308. {
  309. for(const auto & item : config["items"].Vector())
  310. {
  311. button->addOverlay(buildWidget(item));
  312. }
  313. }
  314. if(!config["imageOrder"].isNull())
  315. {
  316. auto imgOrder = config["imageOrder"].Vector();
  317. assert(imgOrder.size() >= 4);
  318. button->setImageOrder(imgOrder[0].Integer(), imgOrder[1].Integer(), imgOrder[2].Integer(), imgOrder[3].Integer());
  319. }
  320. loadButtonBorderColor(button, config["borderColor"]);
  321. loadButtonCallback(button, config["callback"]);
  322. loadButtonHotkey(button, config["hotkey"]);
  323. return button;
  324. }
  325. void InterfaceObjectConfigurable::loadButtonBorderColor(std::shared_ptr<CButton> button, const JsonNode & config) const
  326. {
  327. if (config.isNull())
  328. return;
  329. auto color = readColor(config);
  330. button->setBorderColor(color);
  331. }
  332. void InterfaceObjectConfigurable::loadToggleButtonCallback(std::shared_ptr<CToggleButton> button, const JsonNode & config) const
  333. {
  334. if(config.isNull())
  335. return;
  336. std::string callbackName = config.String();
  337. if (callbacks.count(callbackName) > 0)
  338. button->addCallback(callbacks.at(callbackName));
  339. else
  340. logGlobal->error("Invalid callback '%s' in widget", callbackName );
  341. }
  342. void InterfaceObjectConfigurable::loadButtonCallback(std::shared_ptr<CButton> button, const JsonNode & config) const
  343. {
  344. if(config.isNull())
  345. return;
  346. std::string callbackName = config.String();
  347. if (callbacks.count(callbackName) > 0)
  348. button->addCallback(std::bind(callbacks.at(callbackName), 0));
  349. else
  350. logGlobal->error("Invalid callback '%s' in widget", callbackName );
  351. }
  352. void InterfaceObjectConfigurable::loadButtonHotkey(std::shared_ptr<CButton> button, const JsonNode & config) const
  353. {
  354. if(config.isNull())
  355. return;
  356. if(config.getType() != JsonNode::JsonType::DATA_STRING)
  357. {
  358. logGlobal->error("Invalid shortcut format - string expected!");
  359. return;
  360. }
  361. button->assignedKey = readHotkey(config);
  362. auto target = shortcuts.find(button->assignedKey);
  363. if (target == shortcuts.end())
  364. return;
  365. button->addCallback(target->second.callback);
  366. target->second.assignedToButton = true;
  367. }
  368. std::shared_ptr<CLabelGroup> InterfaceObjectConfigurable::buildLabelGroup(const JsonNode & config) const
  369. {
  370. logGlobal->debug("Building widget CLabelGroup");
  371. auto font = readFont(config["font"]);
  372. auto alignment = readTextAlignment(config["alignment"]);
  373. auto color = readColor(config["color"]);
  374. auto group = std::make_shared<CLabelGroup>(font, alignment, color);
  375. if(!config["items"].isNull())
  376. {
  377. for(const auto & item : config["items"].Vector())
  378. {
  379. auto position = readPosition(item["position"]);
  380. auto text = readText(item["text"]);
  381. group->add(position.x, position.y, text);
  382. }
  383. }
  384. return group;
  385. }
  386. std::shared_ptr<CSlider> InterfaceObjectConfigurable::buildSlider(const JsonNode & config) const
  387. {
  388. logGlobal->debug("Building widget CSlider");
  389. auto position = readPosition(config["position"]);
  390. int length = config["size"].Integer();
  391. auto style = config["style"].String() == "brown" ? CSlider::BROWN : CSlider::BLUE;
  392. auto itemsVisible = config["itemsVisible"].Integer();
  393. auto itemsTotal = config["itemsTotal"].Integer();
  394. auto value = config["selected"].Integer();
  395. bool horizontal = config["orientation"].String() == "horizontal";
  396. const auto & result =
  397. std::make_shared<CSlider>(position, length, callbacks.at(config["callback"].String()), itemsVisible, itemsTotal, value, horizontal, style);
  398. if (!config["scrollBounds"].isNull())
  399. {
  400. Rect bounds = readRect(config["scrollBounds"]);
  401. result->setScrollBounds(bounds);
  402. }
  403. return result;
  404. }
  405. std::shared_ptr<CAnimImage> InterfaceObjectConfigurable::buildImage(const JsonNode & config) const
  406. {
  407. logGlobal->debug("Building widget CAnimImage");
  408. auto position = readPosition(config["position"]);
  409. auto image = config["image"].String();
  410. int group = config["group"].isNull() ? 0 : config["group"].Integer();
  411. int frame = config["frame"].isNull() ? 0 : config["frame"].Integer();
  412. return std::make_shared<CAnimImage>(image, frame, group, position.x, position.y);
  413. }
  414. std::shared_ptr<CFilledTexture> InterfaceObjectConfigurable::buildTexture(const JsonNode & config) const
  415. {
  416. logGlobal->debug("Building widget CFilledTexture");
  417. auto image = config["image"].String();
  418. auto rect = readRect(config["rect"]);
  419. return std::make_shared<CFilledTexture>(image, rect);
  420. }
  421. /// Small helper class that provides ownership for shared_ptr's of child elements
  422. class InterfaceLayoutWidget : public CIntObject
  423. {
  424. public:
  425. std::vector<std::shared_ptr<CIntObject>> ownedChildren;
  426. };
  427. std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildLayout(const JsonNode & config)
  428. {
  429. logGlobal->debug("Building widget Layout");
  430. bool vertical = config["vertical"].Bool();
  431. bool horizontal = config["horizontal"].Bool();
  432. bool dynamic = config["dynamic"].Bool();
  433. int distance = config["distance"].Integer();
  434. std::string customType = config["customType"].String();
  435. auto position = readPosition(config["position"]);
  436. auto result = std::make_shared<InterfaceLayoutWidget>();
  437. result->moveBy(position);
  438. Point layoutPosition;
  439. for(auto item : config["items"].Vector())
  440. {
  441. if (item["type"].String().empty())
  442. item["type"].String() = customType;
  443. if (!item["created"].isNull())
  444. {
  445. std::string name = item["created"].String();
  446. if (conditionals.count(name) != 0)
  447. {
  448. if (!conditionals.at(name))
  449. continue;
  450. }
  451. else
  452. {
  453. logMod->warn("Unknown condition %s in widget!", name);
  454. }
  455. }
  456. auto widget = buildWidget(item);
  457. addWidget(item["name"].String(), widget);
  458. result->ownedChildren.push_back(widget);
  459. result->addChild(widget.get(), false);
  460. widget->moveBy(position + layoutPosition);
  461. if (dynamic && vertical)
  462. layoutPosition.y += widget->pos.h;
  463. if (dynamic && horizontal)
  464. layoutPosition.x += widget->pos.w;
  465. if (vertical)
  466. layoutPosition.y += distance;
  467. if (horizontal)
  468. layoutPosition.x += distance;
  469. }
  470. return result;
  471. }
  472. std::shared_ptr<CShowableAnim> InterfaceObjectConfigurable::buildAnimation(const JsonNode & config) const
  473. {
  474. logGlobal->debug("Building widget CShowableAnim");
  475. auto position = readPosition(config["position"]);
  476. auto image = config["image"].String();
  477. ui8 flags = 0;
  478. if(!config["repeat"].Bool())
  479. flags |= CShowableAnim::EFlags::PLAY_ONCE;
  480. int group = config["group"].isNull() ? 0 : config["group"].Integer();
  481. auto anim = std::make_shared<CShowableAnim>(position.x, position.y, image, flags, 4, group);
  482. if(!config["alpha"].isNull())
  483. anim->setAlpha(config["alpha"].Integer());
  484. if(!config["callback"].isNull())
  485. anim->callback = std::bind(callbacks.at(config["callback"].String()), 0);
  486. if(!config["frames"].isNull())
  487. {
  488. auto b = config["frames"]["start"].Integer();
  489. auto e = config["frames"]["end"].Integer();
  490. anim->set(group, b, e);
  491. }
  492. return anim;
  493. }
  494. std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildWidget(JsonNode config) const
  495. {
  496. assert(!config.isNull());
  497. logGlobal->debug("Building widget from config");
  498. //overrides from variables
  499. for(auto & item : config["overrides"].Struct())
  500. {
  501. logGlobal->debug("Config attribute %s was overriden by variable %s", item.first, item.second.String());
  502. config[item.first] = variables[item.second.String()];
  503. }
  504. auto type = config["type"].String();
  505. auto buildIterator = builders.find(type);
  506. if(buildIterator != builders.end())
  507. return (buildIterator->second)(config);
  508. logGlobal->error("Builder with type %s is not registered", type);
  509. return nullptr;
  510. }
  511. void InterfaceObjectConfigurable::setShortcutBlocked(EShortcut shortcut, bool isBlocked)
  512. {
  513. auto target = shortcuts.find(shortcut);
  514. if (target == shortcuts.end())
  515. return;
  516. target->second.blocked = isBlocked;
  517. for (auto & entry : widgets)
  518. {
  519. auto button = std::dynamic_pointer_cast<CButton>(entry.second);
  520. if (button && button->assignedKey == shortcut)
  521. button->block(isBlocked);
  522. }
  523. }
  524. void InterfaceObjectConfigurable::addShortcut(EShortcut shortcut, std::function<void()> callback)
  525. {
  526. assert(shortcuts.count(shortcut) == 0);
  527. shortcuts[shortcut].callback = callback;
  528. }
  529. void InterfaceObjectConfigurable::keyPressed(EShortcut key)
  530. {
  531. auto target = shortcuts.find(key);
  532. if (target == shortcuts.end())
  533. return;
  534. if (target->second.assignedToButton)
  535. return; // will be handled by button instance
  536. if (target->second.blocked)
  537. return;
  538. target->second.callback();
  539. }