UIWidget.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. //--player --editor-resource-paths "/Users/josh/Dev/atomic/AtomicGameEngine/Data/AtomicPlayer/Resources/CoreData!/Users/josh/Dev/atomic/AtomicGameEngine/Data/AtomicPlayer/Resources/PlayerData!/Users/josh/Dev/atomic/AtomicExamples/UIExample/Resources"
  23. #include "../IO/Log.h"
  24. #include "../Input/InputEvents.h"
  25. #include "UIEvents.h"
  26. #include "UI.h"
  27. #include "UIWidget.h"
  28. #include "UILayout.h"
  29. #include "UIFontDescription.h"
  30. #include "UIView.h"
  31. using namespace tb;
  32. namespace Atomic
  33. {
  34. UIWidget::UIWidget(Context* context, bool createWidget) : Object(context),
  35. widget_(0),
  36. preferredSize_(new UIPreferredSize()),
  37. multiTouch_(false)
  38. {
  39. AddRef();
  40. if (createWidget)
  41. {
  42. widget_ = new TBWidget();
  43. widget_->SetDelegate(this);
  44. GetSubsystem<UI>()->WrapWidget(this, widget_);
  45. }
  46. }
  47. UIWidget::~UIWidget()
  48. {
  49. }
  50. void UIWidget::SetIsFocusable(bool value)
  51. {
  52. if (!widget_)
  53. return;
  54. widget_->SetIsFocusable(value);
  55. }
  56. bool UIWidget::Load(const String& filename)
  57. {
  58. UI* ui = GetSubsystem<UI>();
  59. if (!ui->LoadResourceFile(widget_ , filename))
  60. return false;
  61. VariantMap eventData;
  62. eventData[WidgetLoaded::P_WIDGET] = this;
  63. SendEvent(E_WIDGETLOADED, eventData);
  64. return true;
  65. }
  66. UIPreferredSize* UIWidget::GetPreferredSize()
  67. {
  68. // error
  69. if (!widget_)
  70. return preferredSize_;
  71. preferredSize_->SetFromTBPreferredSize(widget_->GetPreferredSize());
  72. return preferredSize_;
  73. }
  74. UIWidget* UIWidget::GetWidget(const String& id)
  75. {
  76. if (!widget_)
  77. return 0;
  78. TBWidget* child = widget_->GetWidgetByID(TBID(id.CString()));
  79. if (!child)
  80. return 0;
  81. UI* ui = GetSubsystem<UI>();
  82. return ui->WrapWidget(child);
  83. }
  84. void UIWidget::SetWidget(tb::TBWidget* widget)
  85. {
  86. widget_ = widget;
  87. widget_->SetDelegate(this);
  88. }
  89. /*
  90. enum SPECIAL_KEY
  91. {
  92. TB_KEY_UNDEFINED = 0,
  93. TB_KEY_UP, TB_KEY_DOWN, TB_KEY_LEFT, TB_KEY_RIGHT,
  94. TB_KEY_PAGE_UP, TB_KEY_PAGE_DOWN, TB_KEY_HOME, TB_KEY_END,
  95. TB_KEY_TAB, TB_KEY_BACKSPACE, TB_KEY_INSERT, TB_KEY_DELETE,
  96. TB_KEY_ENTER, TB_KEY_ESC,
  97. TB_KEY_F1, TB_KEY_F2, TB_KEY_F3, TB_KEY_F4, TB_KEY_F5, TB_KEY_F6,
  98. TB_KEY_F7, TB_KEY_F8, TB_KEY_F9, TB_KEY_F10, TB_KEY_F11, TB_KEY_F12
  99. };
  100. */
  101. void UIWidget::ConvertEvent(UIWidget *handler, UIWidget* target, const tb::TBWidgetEvent &ev, VariantMap& data)
  102. {
  103. UI* ui = GetSubsystem<UI>();
  104. String refid;
  105. ui->GetTBIDString(ev.ref_id, refid);
  106. int key = ev.key;
  107. if (ev.special_key)
  108. {
  109. switch (ev.special_key)
  110. {
  111. case TB_KEY_ENTER:
  112. key = KEY_RETURN;
  113. break;
  114. case TB_KEY_BACKSPACE:
  115. key = KEY_BACKSPACE;
  116. break;
  117. case TB_KEY_DELETE:
  118. key = KEY_DELETE;
  119. break;
  120. case TB_KEY_DOWN:
  121. key = KEY_DOWN;
  122. break;
  123. case TB_KEY_UP:
  124. key = KEY_UP;
  125. break;
  126. case TB_KEY_LEFT:
  127. key = KEY_LEFT;
  128. break;
  129. case TB_KEY_RIGHT:
  130. key = KEY_RIGHT;
  131. break;
  132. default:
  133. break;
  134. }
  135. }
  136. unsigned modifierKeys = 0;
  137. if( ev.special_key && TB_SHIFT)
  138. modifierKeys |= QUAL_SHIFT;
  139. if( ev.special_key && TB_CTRL)
  140. modifierKeys |= QUAL_CTRL;
  141. if( ev.special_key && TB_ALT)
  142. modifierKeys |= QUAL_ALT;
  143. using namespace WidgetEvent;
  144. data[P_HANDLER] = handler;
  145. data[P_TARGET] = target;
  146. data[P_TYPE] = (unsigned) ev.type;
  147. data[P_X] = ev.target_x;
  148. data[P_Y] = ev.target_y;
  149. data[P_DELTAX] = ev.delta_x;
  150. data[P_DELTAY] = ev.delta_y;
  151. data[P_COUNT] = ev.count;
  152. data[P_KEY] = key;
  153. data[P_SPECIALKEY] = (unsigned) ev.special_key;
  154. data[P_MODIFIERKEYS] = modifierKeys;
  155. data[P_REFID] = refid;
  156. data[P_TOUCH] = (unsigned) ev.touch;
  157. }
  158. void UIWidget::OnDelete()
  159. {
  160. if (widget_)
  161. {
  162. // if we don't have a UI subsystem, we are exiting
  163. UI* ui = GetSubsystem<UI>();
  164. if (ui)
  165. ui->UnwrapWidget(widget_);
  166. }
  167. widget_ = 0;
  168. VariantMap eventData;
  169. eventData[WidgetDeleted::P_WIDGET] = this;
  170. SendEvent(E_WIDGETDELETED, eventData);
  171. UnsubscribeFromAllEvents();
  172. ReleaseRef();
  173. }
  174. void UIWidget::AddChildAfter(UIWidget* child, UIWidget* otherChild)
  175. {
  176. if (!widget_ || !child || !child->widget_ || !otherChild || !otherChild->widget_)
  177. return;
  178. widget_->AddChildRelative(child->widget_, tb::WIDGET_Z_REL_AFTER, otherChild->widget_);
  179. }
  180. void UIWidget::AddChildBefore(UIWidget* child, UIWidget* otherChild)
  181. {
  182. if (!widget_ || !child || !child->widget_ || !otherChild || !otherChild->widget_)
  183. return;
  184. widget_->AddChildRelative(child->widget_, tb::WIDGET_Z_REL_BEFORE, otherChild->widget_);
  185. }
  186. void UIWidget::AddChild(UIWidget* child)
  187. {
  188. if (!widget_ || !child || !child->widget_)
  189. return;
  190. widget_->AddChild(child->widget_);
  191. }
  192. void UIWidget::AddChildRelative(UIWidget* child, UI_WIDGET_Z_REL z, UIWidget* reference)
  193. {
  194. if (!widget_ || !child || !child->widget_ || !reference || !reference->widget_)
  195. return;
  196. widget_->AddChildRelative(child->widget_, (WIDGET_Z_REL) z, reference->widget_);
  197. }
  198. String UIWidget::GetText()
  199. {
  200. if (!widget_)
  201. return "";
  202. return widget_->GetText().CStr();
  203. }
  204. void UIWidget::SetText(const String& text)
  205. {
  206. if (!widget_)
  207. return;
  208. widget_->SetText(text.CString());
  209. }
  210. void UIWidget::SetGravity(UI_GRAVITY gravity)
  211. {
  212. if (!widget_)
  213. return;
  214. widget_->SetGravity((WIDGET_GRAVITY) gravity);
  215. }
  216. bool UIWidget::IsAncestorOf(UIWidget* widget)
  217. {
  218. if (!widget_ || !widget || !widget->widget_)
  219. return false;
  220. return widget_->IsAncestorOf(widget->widget_);
  221. }
  222. void UIWidget::SetPosition(int x, int y)
  223. {
  224. if (!widget_)
  225. return;
  226. widget_->SetPosition(TBPoint(x, y));
  227. }
  228. IntRect UIWidget::GetRect()
  229. {
  230. IntRect rect(0, 0, 0, 0);
  231. if (!widget_)
  232. return rect;
  233. tb::TBRect tbrect = widget_->GetRect();
  234. rect.top_ = tbrect.y;
  235. rect.left_ = tbrect.x;
  236. rect.right_ = tbrect.x + tbrect.w;
  237. rect.bottom_ = tbrect.y + tbrect.h;
  238. return rect;
  239. }
  240. void UIWidget::SetRect(IntRect rect)
  241. {
  242. if (!widget_)
  243. return;
  244. tb::TBRect tbrect;
  245. tbrect.y = rect.top_;
  246. tbrect.x = rect.left_;
  247. tbrect.w = rect.right_ - rect.left_;
  248. tbrect.h = rect.bottom_ - rect.top_;
  249. widget_->SetRect(tbrect);
  250. }
  251. void UIWidget::SetSize(int width, int height)
  252. {
  253. if (!widget_)
  254. return;
  255. widget_->SetSize(width, height);
  256. }
  257. void UIWidget::Invalidate()
  258. {
  259. if (!widget_)
  260. return;
  261. widget_->Invalidate();
  262. }
  263. void UIWidget::Center()
  264. {
  265. if (!widget_)
  266. return;
  267. TBRect rect = widget_->GetRect();
  268. TBWidget* root = widget_->GetParent();
  269. if (!root)
  270. {
  271. UI* ui = GetSubsystem<UI>();
  272. root = ui->GetRootWidget();
  273. }
  274. TBRect bounds(0, 0, root->GetRect().w, root->GetRect().h);
  275. widget_->SetRect(rect.CenterIn(bounds).MoveIn(bounds).Clip(bounds));
  276. }
  277. UIWidget* UIWidget::GetParent()
  278. {
  279. if (!widget_)
  280. return 0;
  281. TBWidget* parent = widget_->GetParent();
  282. if (!parent)
  283. return 0;
  284. UI* ui = GetSubsystem<UI>();
  285. return ui->WrapWidget(parent);
  286. }
  287. UIWidget* UIWidget::GetContentRoot()
  288. {
  289. if (!widget_)
  290. return 0;
  291. TBWidget* root = widget_->GetContentRoot();
  292. if (!root)
  293. return 0;
  294. UI* ui = GetSubsystem<UI>();
  295. return ui->WrapWidget(root);
  296. }
  297. void UIWidget::Die()
  298. {
  299. if (!widget_)
  300. return;
  301. // clear delegate
  302. widget_->SetDelegate(NULL);
  303. // explictly die (can trigger an animation)
  304. widget_->Die();
  305. // call OnDelete, which unwraps the widget and does some bookkeeping
  306. OnDelete();
  307. }
  308. void UIWidget::SetLayoutParams(UILayoutParams* params)
  309. {
  310. if (!widget_)
  311. return;
  312. widget_->SetLayoutParams(*(params->GetTBLayoutParams()));
  313. }
  314. void UIWidget::SetFontDescription(UIFontDescription* fd)
  315. {
  316. if (!widget_)
  317. return;
  318. widget_->SetFontDescription(*(fd->GetTBFontDescription()));
  319. }
  320. void UIWidget::DeleteAllChildren()
  321. {
  322. if (!widget_)
  323. return;
  324. widget_->DeleteAllChildren();
  325. }
  326. void UIWidget::SetSkinBg(const String& id)
  327. {
  328. if (!widget_)
  329. return;
  330. widget_->SetSkinBg(TBIDC(id.CString()));
  331. }
  332. void UIWidget::Remove()
  333. {
  334. if (!widget_ || !widget_->GetParent())
  335. return;
  336. widget_->GetParent()->RemoveChild(widget_);
  337. }
  338. void UIWidget::RemoveChild(UIWidget* child, bool cleanup)
  339. {
  340. if (!widget_ || !child)
  341. return;
  342. TBWidget* childw = child->GetInternalWidget();
  343. if (!childw)
  344. return;
  345. widget_->RemoveChild(childw);
  346. if (cleanup)
  347. delete childw;
  348. }
  349. const String& UIWidget::GetId()
  350. {
  351. if (!widget_ || !widget_->GetID())
  352. {
  353. if (id_.Length())
  354. id_.Clear();
  355. return id_;
  356. }
  357. if (id_.Length())
  358. return id_;
  359. UI* ui = GetSubsystem<UI>();
  360. ui->GetTBIDString(widget_->GetID(), id_);
  361. return id_;
  362. }
  363. void UIWidget::SetId(const String& id)
  364. {
  365. if (!widget_)
  366. {
  367. if (id_.Length())
  368. id_.Clear();
  369. return;
  370. }
  371. id_ = id;
  372. widget_->SetID(TBIDC(id.CString()));
  373. }
  374. void UIWidget::SetState(UI_WIDGET_STATE state, bool on)
  375. {
  376. if (!widget_)
  377. return;
  378. widget_->SetState((WIDGET_STATE) state, on);
  379. }
  380. void UIWidget::SetFocus()
  381. {
  382. if (!widget_)
  383. return;
  384. widget_->SetFocus(WIDGET_FOCUS_REASON_UNKNOWN);
  385. }
  386. bool UIWidget::GetFocus()
  387. {
  388. if (!widget_)
  389. return false;
  390. return widget_->GetIsFocused();
  391. }
  392. void UIWidget::SetFocusRecursive()
  393. {
  394. if (!widget_)
  395. return;
  396. widget_->SetFocusRecursive(WIDGET_FOCUS_REASON_UNKNOWN);
  397. }
  398. void UIWidget::SetVisibility(UI_WIDGET_VISIBILITY visibility)
  399. {
  400. if (!widget_)
  401. return;
  402. widget_->SetVisibilility((WIDGET_VISIBILITY) visibility);
  403. }
  404. UI_WIDGET_VISIBILITY UIWidget::GetVisibility()
  405. {
  406. if (!widget_)
  407. return UI_WIDGET_VISIBILITY_GONE;
  408. return (UI_WIDGET_VISIBILITY) widget_->GetVisibility();
  409. }
  410. UIWidget* UIWidget::GetFirstChild()
  411. {
  412. if (!widget_)
  413. return NULL;
  414. return GetSubsystem<UI>()->WrapWidget(widget_->GetFirstChild());
  415. }
  416. UIWidget* UIWidget::GetNext()
  417. {
  418. if (!widget_)
  419. return NULL;
  420. return GetSubsystem<UI>()->WrapWidget(widget_->GetNext());
  421. }
  422. void UIWidget::SetValue(double value)
  423. {
  424. if (!widget_)
  425. return;
  426. widget_->SetValueDouble(value);
  427. }
  428. double UIWidget::GetValue()
  429. {
  430. if (!widget_)
  431. return 0.0;
  432. return widget_->GetValueDouble();
  433. }
  434. bool UIWidget::GetState(UI_WIDGET_STATE state)
  435. {
  436. if (!widget_)
  437. return false;
  438. return widget_->GetState((WIDGET_STATE) state);
  439. }
  440. void UIWidget::SetStateRaw(UI_WIDGET_STATE state)
  441. {
  442. if (!widget_)
  443. return;
  444. widget_->SetStateRaw((WIDGET_STATE) state);
  445. }
  446. UI_WIDGET_STATE UIWidget::GetStateRaw()
  447. {
  448. if (!widget_)
  449. return UI_WIDGET_STATE_NONE;
  450. return (UI_WIDGET_STATE) widget_->GetStateRaw();
  451. }
  452. UIView* UIWidget::GetView()
  453. {
  454. if (!widget_)
  455. return 0;
  456. if (GetType() == UIView::GetTypeStatic())
  457. return (UIView*) this;
  458. TBWidget* tbw = widget_->GetParent();
  459. while(tbw)
  460. {
  461. TBWidgetDelegate* delegate = tbw->GetDelegate();
  462. if (delegate)
  463. {
  464. UIWidget* d = (UIWidget*) delegate;
  465. if (d->GetType() == UIView::GetTypeStatic())
  466. return (UIView*) d;
  467. }
  468. tbw = tbw->GetParent();
  469. }
  470. return 0;
  471. }
  472. void UIWidget::OnFocusChanged(bool focused)
  473. {
  474. using namespace WidgetFocusChanged;
  475. VariantMap eventData;
  476. eventData[P_WIDGET] = this;
  477. eventData[P_FOCUSED] = focused;
  478. SendEvent(E_WIDGETFOCUSCHANGED, eventData);
  479. }
  480. bool UIWidget::OnEvent(const tb::TBWidgetEvent &ev)
  481. {
  482. UI* ui = GetSubsystem<UI>();
  483. if ((ev.type == EVENT_TYPE_CHANGED && !ui->GetBlockChangedEvents()) || ev.type == EVENT_TYPE_KEY_UP)
  484. {
  485. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  486. {
  487. VariantMap eventData;
  488. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  489. SendEvent(E_WIDGETEVENT, eventData);
  490. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  491. return true;
  492. }
  493. }
  494. else if (ev.type == EVENT_TYPE_RIGHT_POINTER_UP)
  495. {
  496. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  497. {
  498. VariantMap eventData;
  499. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  500. SendEvent(E_WIDGETEVENT, eventData);
  501. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  502. return true;
  503. }
  504. }
  505. else if (ev.type == EVENT_TYPE_POINTER_DOWN)
  506. {
  507. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  508. {
  509. VariantMap eventData;
  510. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  511. SendEvent(E_WIDGETEVENT, eventData);
  512. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  513. return true;
  514. }
  515. }
  516. else if (ev.type == EVENT_TYPE_SHORTCUT)
  517. {
  518. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  519. {
  520. VariantMap eventData;
  521. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  522. SendEvent(E_WIDGETEVENT, eventData);
  523. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  524. return true;
  525. }
  526. }
  527. else if (ev.type == EVENT_TYPE_TAB_CHANGED)
  528. {
  529. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  530. {
  531. VariantMap eventData;
  532. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  533. SendEvent(E_WIDGETEVENT, eventData);
  534. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  535. return true;
  536. }
  537. }
  538. else if (ev.type == EVENT_TYPE_CLICK)
  539. {
  540. if (ev.target && ev.target->GetID() == TBID("__popup-menu"))
  541. {
  542. // popup menu
  543. if (JSGetHeapPtr())
  544. {
  545. VariantMap eventData;
  546. eventData[PopupMenuSelect::P_BUTTON] = this;
  547. String id;
  548. ui->GetTBIDString(ev.ref_id, id);
  549. eventData[PopupMenuSelect::P_REFID] = id;
  550. SendEvent(E_POPUPMENUSELECT, eventData);
  551. }
  552. return true;
  553. }
  554. else
  555. {
  556. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  557. {
  558. VariantMap eventData;
  559. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  560. SendEvent(E_WIDGETEVENT, eventData);
  561. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  562. return true;
  563. }
  564. }
  565. }
  566. if (ev.type == EVENT_TYPE_CUSTOM)
  567. {
  568. if (!ev.target || ui->IsWidgetWrapped(ev.target))
  569. {
  570. VariantMap eventData;
  571. ConvertEvent(this, ui->WrapWidget(ev.target), ev, eventData);
  572. SendEvent(E_WIDGETEVENT, eventData);
  573. if (eventData[WidgetEvent::P_HANDLED].GetBool())
  574. return true;
  575. }
  576. }
  577. return false;
  578. }
  579. bool UIWidget::GetCaptured()
  580. {
  581. if (!widget_)
  582. return false;
  583. return widget_->IsCaptured();
  584. }
  585. void UIWidget::SetCapturing(bool capturing)
  586. {
  587. if (!widget_)
  588. return;
  589. widget_->SetCapturing(capturing);
  590. }
  591. void UIWidget::InvalidateLayout()
  592. {
  593. if (!widget_)
  594. return;
  595. widget_->InvalidateLayout(tb::TBWidget::INVALIDATE_LAYOUT_TARGET_ONLY);
  596. }
  597. void UIWidget::InvokeShortcut(const String& shortcut)
  598. {
  599. TBWidgetEvent ev(EVENT_TYPE_SHORTCUT);
  600. ev.ref_id = TBIDC(shortcut.CString());
  601. widget_->OnEvent(ev);
  602. }
  603. }