From 9c74519b484b78f4870a95a38eebd02105918350 Mon Sep 17 00:00:00 2001 From: gazer Date: Wed, 27 Jan 2016 20:00:31 +0300 Subject: [PATCH] switching tabs on mouse up --- src/dlangui/widgets/tabs.d | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/dlangui/widgets/tabs.d b/src/dlangui/widgets/tabs.d index 8aa26db0..d1c0f109 100644 --- a/src/dlangui/widgets/tabs.d +++ b/src/dlangui/widgets/tabs.d @@ -264,7 +264,7 @@ class TabControl : WidgetGroupDefaultDrawing { _items = new TabItemList(); _moreButton = new ImageButton("MORE", "tab_more"); _moreButton.styleId = STYLE_BUTTON_TRANSPARENT; - _moreButton.click = &onClick; + _moreButton.mouseEvent = &onMouse; _moreButton.margins(Rect(3,3,3,6)); _enableCloseButton = true; styleId = _tabStyle; @@ -407,7 +407,7 @@ class TabControl : WidgetGroupDefaultDrawing { _items.insert(item, index); TabItemWidget widget = new TabItemWidget(item, enableCloseButton); widget.parent = this; - widget.click = &onClick; + widget.mouseEvent = &onMouse; widget.setStyles(_tabButtonStyle, _tabButtonTextStyle); widget.tabClose = &onTabClose; _children.insert(widget, index); @@ -425,15 +425,17 @@ class TabControl : WidgetGroupDefaultDrawing { TabItem item = new TabItem(id, labelResourceId, iconId); return addTab(item, -1, enableCloseButton); } - protected bool onClick(Widget source) { - if (source.compareId("MORE")) { - Log.d("tab MORE button pressed"); - return true; - } - string id = source.id; - int index = tabIndex(id); - if (index >= 0) { - selectTab(index, true); + protected bool onMouse(Widget source, MouseEvent event) { + if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) { + if (source.compareId("MORE")) { + Log.d("tab MORE button pressed"); + return true; + } + string id = source.id; + int index = tabIndex(id); + if (index >= 0) { + selectTab(index, true); + } } return true; }