本文整理汇总了C++中TBWidget::GetDelegate方法的典型用法代码示例。如果您正苦于以下问题:C++ TBWidget::GetDelegate方法的具体用法?C++ TBWidget::GetDelegate怎么用?C++ TBWidget::GetDelegate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBWidget
的用法示例。
在下文中一共展示了TBWidget::GetDelegate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMouseDown
void UIDragDrop::HandleMouseDown(StringHash eventType, VariantMap& eventData)
{
using namespace MouseButtonDown;
Input* input = GetSubsystem<Input>();
if (!input->IsMouseVisible())
return;
if ((eventData[P_BUTTONS].GetUInt() & MOUSEB_LEFT) && TBWidget::hovered_widget)
{
// see if we have a widget
TBWidget* tbw = TBWidget::hovered_widget;
while(tbw && !tbw->GetDelegate())
{
tbw = tbw->GetParent();
}
if (!tbw)
return;
UIWidget* widget = (UIWidget*) tbw->GetDelegate();
currentTargetWidget_ = widget;
dragSourceWidget_ = widget;
}
}
示例2: HandleMouseDown
void UIDragDrop::HandleMouseDown(StringHash eventType, VariantMap& eventData)
{
using namespace MouseButtonDown;
Input* input = GetSubsystem<Input>();
if (!input->IsMouseVisible())
return;
if ((eventData[P_BUTTONS].GetUInt() & MOUSEB_LEFT) && TBWidget::hovered_widget)
{
// see if we have a widget with a drag object
TBWidget* tbw = TBWidget::hovered_widget;
UIWidget* widget = nullptr;
while(tbw)
{
if (tbw->GetDelegate())
{
widget = (UIWidget*) tbw->GetDelegate();
if (widget->GetDragObject())
{
// TODO: check if we're in widget bounds
// this is going to need to be updated for drag/drop multiselect
break;
}
widget = nullptr;
}
tbw = tbw->GetParent();
}
if (!widget)
return;
currentTargetWidget_ = widget;
dragSourceWidget_ = widget;
mouseDownPosition_ = input->GetMousePosition();
}
}
示例3: GetView
UIView* UIWidget::GetView()
{
if (!widget_)
return 0;
if (GetType() == UIView::GetTypeStatic())
return (UIView*) this;
TBWidget* tbw = widget_->GetParent();
while(tbw)
{
TBWidgetDelegate* delegate = tbw->GetDelegate();
if (delegate)
{
UIWidget* d = (UIWidget*) delegate;
if (d->GetType() == UIView::GetTypeStatic())
return (UIView*) d;
}
tbw = tbw->GetParent();
}
return 0;
}
示例4: InvokeShortcut
static bool InvokeShortcut(UI* ui, int key, SPECIAL_KEY special_key, MODIFIER_KEYS modifierkeys, bool down)
{
#ifdef __APPLE__
bool shortcut_key = (modifierkeys & TB_SUPER) ? true : false;
#else
bool shortcut_key = (modifierkeys & TB_CTRL) ? true : false;
#endif
if (!down || (!shortcut_key && special_key ==TB_KEY_UNDEFINED))
return false;
bool reverse_key = (modifierkeys & TB_SHIFT) ? true : false;
int upper_key = toupr_ascii(key);
TBID id;
if (upper_key == 'X')
id = TBIDC("cut");
else if (upper_key == 'C' || special_key == TB_KEY_INSERT)
id = TBIDC("copy");
else if (upper_key == 'V' || (special_key == TB_KEY_INSERT && reverse_key))
id = TBIDC("paste");
else if (upper_key == 'A')
id = TBIDC("selectall");
else if (upper_key == 'Z' || upper_key == 'Y')
{
bool undo = upper_key == 'Z';
if (reverse_key)
undo = !undo;
id = undo ? TBIDC("undo") : TBIDC("redo");
}
else if (upper_key == 'N')
id = TBIDC("new");
else if (upper_key == 'O')
id = TBIDC("open");
else if (upper_key == 'S')
id = TBIDC("save");
else if (upper_key == 'W')
id = TBIDC("close");
else if (upper_key == 'F')
id = TBIDC("find");
#ifdef ATOMIC_PLATFORM_OSX
else if (upper_key == 'G' && (modifierkeys & TB_SHIFT))
id = TBIDC("findprev");
else if (upper_key == 'G')
id = TBIDC("findnext");
#else
else if (special_key == TB_KEY_F3 && (modifierkeys & TB_SHIFT))
id = TBIDC("findprev");
else if (special_key == TB_KEY_F3)
id = TBIDC("findnext");
#endif
else if (upper_key == 'P')
id = TBIDC("play");
else if (special_key == TB_KEY_PAGE_UP)
id = TBIDC("prev_doc");
else if (special_key == TB_KEY_PAGE_DOWN)
id = TBIDC("next_doc");
else
return false;
TBWidgetEvent ev(EVENT_TYPE_SHORTCUT);
ev.modifierkeys = modifierkeys;
ev.ref_id = id;
TBWidget* eventWidget = TBWidget::focused_widget;
if (id == TBIDC("save") || id == TBIDC("close")) {
while (eventWidget && !eventWidget->GetDelegate()) {
eventWidget = eventWidget->GetParent();
}
}
if (!eventWidget || !eventWidget->InvokeEvent(ev))
{
VariantMap evData;
evData[UIUnhandledShortcut::P_REFID] = id;
ui->SendEvent(E_UIUNHANDLEDSHORTCUT, evData);
return false;
}
return true;
}
示例5: HandleMouseMove
void UIDragDrop::HandleMouseMove(StringHash eventType, VariantMap& eventData)
{
if (dragObject_.Null() && dragSourceWidget_.Null())
return;
if (dragObject_.Null())
{
dragObject_ = dragSourceWidget_->GetDragObject();
if (dragObject_.Null())
{
dragSourceWidget_ = 0;
return;
}
}
using namespace MouseMove;
int x = eventData[P_X].GetInt();
int y = eventData[P_Y].GetInt();
// tolerance to 8 pixels to start drag/drop operation
IntVector2 mousePos(x, y);
mousePos -= mouseDownPosition_;
if (Abs(mousePos.x_) < 8 && Abs(mousePos.y_) < 8)
return;
// initialize if necessary
if (dragLayout_->GetVisibility() == UI_WIDGET_VISIBILITY_GONE)
{
dragLayout_->GetInternalWidget()->SetZ(WIDGET_Z_TOP);
dragLayout_->SetVisibility(UI_WIDGET_VISIBILITY_VISIBLE);
dragText_->SetText(dragObject_->GetText());
UIPreferredSize* sz = dragLayout_->GetPreferredSize();
dragLayout_->SetRect(IntRect(0, 0, sz->GetMinWidth(), sz->GetMinHeight()));
}
// see if we have a widget
TBWidget* tbw = TBWidget::hovered_widget;
while(tbw && (!tbw->GetDelegate() || tbw->IsOfType<TBLayout>()))
{
tbw = tbw->GetParent();
}
if (!tbw || !tbw->GetParent())
return;
UIWidget* hoverWidget = (UIWidget*) tbw->GetDelegate();
if (!hoverWidget->GetInternalWidget())
return;
if (hoverWidget != currentTargetWidget_)
{
if (currentTargetWidget_)
{
VariantMap exitData;
exitData[DragExitWidget::P_WIDGET] = currentTargetWidget_;
exitData[DragExitWidget::P_DRAGOBJECT] = dragObject_;
currentTargetWidget_->SendEvent(E_DRAGEXITWIDGET, exitData);
}
currentTargetWidget_ = hoverWidget;
VariantMap enterData;
enterData[DragEnterWidget::P_WIDGET] = currentTargetWidget_;
enterData[DragEnterWidget::P_DRAGOBJECT] = dragObject_;
currentTargetWidget_->SendEvent(E_DRAGENTERWIDGET, enterData);
}
dragLayout_->SetPosition(x, y - 20);
}