Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed bug in TabControl that prevent content event bindings from wiri…

…ng up if the content was not in the first tab.
  • Loading branch information...
commit eddd8c1ffd715e5f4b48e03407819fad9994cf41 1 parent b5f4437
@prujohn prujohn authored
View
6 example/sandbox/web/viewmodels/master_viewmodel.dart
@@ -262,6 +262,12 @@ class MasterViewModel extends ViewModelBase
registerEventHandler('demotreeview_selection', demotreeview_selection);
registerEventHandler('dockpanel_click', dockpanel_click);
registerEventHandler('selection_handler', selection_handler);
+ registerEventHandler('debug_click', debug_click);
+ }
+
+
+ void debug_click(sender, args){
+ db('fired click event', sender);
}
/**
View
16 lib/extensions/controls/tab_control/tab_control.dart
@@ -77,9 +77,7 @@ class TabControl extends Control implements IFrameworkContainer
setValue(t.backgroundProperty,
getValue(tabSelectedBrushProperty));
- setValue(currentContentProperty,
- getValue(currentTab.contentProperty));
-
+ setValue(currentContentProperty, getValue(currentTab.contentProperty));
}
void closeTab(TabItem tab){
@@ -109,6 +107,7 @@ class TabControl extends Control implements IFrameworkContainer
int i = 0;
pc.forEach((e){
final ti = tabItems[i++];
+ ti.parent = this;
ti._visualTemplate = e;
e.mouseUp + (_, __){
tabSelected.invokeAsync(this, new TabSelectedEventArgs(ti));
@@ -191,9 +190,14 @@ class TabControl extends Control implements IFrameworkContainer
</border>
</itemstemplate>
</collectionpresenter>
- <border grid.row='1' halign='stretch' bordercolor='{resource theme_border_color}' borderthickness='{resource theme_border_thickness}' valign='stretch' background='{template background}' padding='{resource theme_border_padding}'>
- <contentpresenter content='{template currentContent}' />
- </border>
+ <border name='__content_border__' content='{template currentContent}'
+ grid.row='1'
+ halign='stretch'
+ valign='stretch'
+ bordercolor='{resource theme_border_color}'
+ borderthickness='{resource theme_border_thickness}'
+ background='{template background}'
+ padding='{resource theme_border_padding}' />
</grid>
</template>
</controltemplate>
View
40 lib/extensions/controls/tab_control/tab_item.dart
@@ -9,45 +9,51 @@ class TabItem extends Control implements IFrameworkContainer
FrameworkProperty closeEnabledProperty;
FrameworkProperty closeButtonVisiblityProperty;
FrameworkProperty contentProperty;
-
+
FrameworkElement _visualTemplate;
-
+
TabItem(){
- Browser.appendClass(rawElement, "TabItem");
-
+ Browser.appendClass(rawElement, "TabItem");
+
_initTabItemProperties();
-
+
stateBag[FrameworkObject.CONTAINER_CONTEXT] = contentProperty;
}
-
+
TabItem.register() : super.register();
makeMe() => new TabItem();
-
+
get content => getValue(contentProperty);
-
+
void _initTabItemProperties(){
headerProperty = new FrameworkProperty(this, 'header');
-
+
iconProperty = new FrameworkProperty(this, 'icon');
-
- contentProperty = new FrameworkProperty(this, 'content',
- defaultValue: '');
-
- closeButtonVisiblityProperty = new FrameworkProperty(this,
+
+ contentProperty = new FrameworkProperty(this, 'content',
+ propertyChangedCallback:(value){
+ // ensure that the content has a parent assigned so that
+ // .onAddedToDOM() will bind events successfully.
+ if (value is FrameworkElement && value.parent == null){
+ value.parent = this;
+ }
+ });
+
+ closeButtonVisiblityProperty = new FrameworkProperty(this,
'closeButtonVisibility',
propertyChangedCallback: (Visibility value){
- if (value == Visibility.visible
+ if (value == Visibility.visible
&& getValue(closeEnabledProperty) == false){
setValue(closeButtonVisiblityProperty, Visibility.collapsed);
}
},
defaultValue: Visibility.collapsed,
converter: const StringToVisibilityConverter());
-
+
closeEnabledProperty = new FrameworkProperty(this, 'closeEnabled',
propertyChangedCallback: (bool value){
if (value == false){
- setValue(closeButtonVisiblityProperty, Visibility.collapsed);
+ setValue(closeButtonVisiblityProperty, Visibility.collapsed);
}
},
defaultValue: true,
View
8 lib/src/controls/control/control.dart
@@ -30,7 +30,7 @@ class Control extends FrameworkElement
Browser.appendClass(rawElement, "control");
_initControlProperties();
}
-
+
Control.register() : super.register(),
_c = new Completer();
makeMe() => null;
@@ -96,12 +96,12 @@ class Control extends FrameworkElement
_templateBindingsApplied = true;
_bindTemplateBindings();
-
+
finishOnLoaded();
}
-
+
finishOnLoaded(){
- template._onAddedToDOM();
+ template.onAddedToDOM();
}
onUnLoaded(){
View
10 lib/src/core/framework_object.dart
@@ -228,12 +228,10 @@ class FrameworkObject extends BuckshotObject
if (!parentElement.isLoaded) return;
- _onAddedToDOM();
+ onAddedToDOM();
}
- void onAddedToDOM() => _onAddedToDOM();
-
- void _onAddedToDOM(){
+ void onAddedToDOM(){
//parent is in the DOM so we should call loaded event and check for children
updateDataContext();
@@ -262,10 +260,10 @@ class FrameworkObject extends BuckshotObject
.forEach((FrameworkElement child)
{
child.parent = this;
- child._onAddedToDOM();
+ child.onAddedToDOM();
});
}else if (containerContent is FrameworkElement){
- containerContent._onAddedToDOM();
+ containerContent.onAddedToDOM();
}
}
View
8 lib/src/core/globals.dart
@@ -219,7 +219,7 @@ printTree(startWith, [int indent = 0]){
return s.toString();
}
- print('${space(indent)}${startWith}(Parent=${startWith.parent})');
+ print('${space(indent)}${_elementAndName(startWith)}(Parent=${_elementAndName(startWith.parent)})');
if (startWith is IFrameworkContainer){
if ((startWith as IFrameworkContainer).content is List){
@@ -232,6 +232,12 @@ printTree(startWith, [int indent = 0]){
}
}
+String _elementAndName(FrameworkObject o){
+ return (o == null || o.name == null || o.name.trim() == '')
+ ? '$o'
+ : '$o[${o.name}]';
+}
+
Future _functionToFuture(Function f){
Completer c = new Completer();
View
5 lib/src/elements/content_presenter.dart
@@ -17,11 +17,11 @@ class ContentPresenter extends FrameworkElement implements IFrameworkContainer
Browser.appendClass(rawElement, "ContentPresenter");
stateBag[FrameworkObject.CONTAINER_CONTEXT] = contentProperty;
-
+
_initContentPresenterProperties();
}
-
+
ContentPresenter.register() : super.register();
makeMe() => new ContentPresenter();
@@ -51,7 +51,6 @@ class ContentPresenter extends FrameworkElement implements IFrameworkContainer
}
currentContent = value;
-
value.addToLayoutTree(this);
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.