issue #4861, fix widget query method

This commit is contained in:
andyque 2014-05-05 10:10:06 +08:00
parent 503be87675
commit afb65bbebd
1 changed files with 4 additions and 9 deletions

View File

@ -1722,8 +1722,7 @@ Widget* Layout::getPreviousFocusedWidget(FocusDirection dir, Widget *current)
ssize_t previousWidgetPos = _children.getIndex(current); ssize_t previousWidgetPos = _children.getIndex(current);
previousWidgetPos = previousWidgetPos - 1; previousWidgetPos = previousWidgetPos - 1;
if (previousWidgetPos >= 0) { if (previousWidgetPos >= 0) {
//FIXEDME: find the next avalable widget nextWidget = this->getNextWidgetByIndex(previousWidgetPos);
nextWidget = (Widget*)_children.at(previousWidgetPos);
if (nextWidget->isFocusEnabled()) { if (nextWidget->isFocusEnabled()) {
this->dispatchFocusEvent(current, nextWidget); this->dispatchFocusEvent(current, nextWidget);
@ -1747,8 +1746,7 @@ Widget* Layout::getPreviousFocusedWidget(FocusDirection dir, Widget *current)
if (_loopFocus) { if (_loopFocus) {
if (checkFocusEnabledChild()) { if (checkFocusEnabledChild()) {
previousWidgetPos = _children.size()-1; previousWidgetPos = _children.size()-1;
//FIXEDME: find the next avalable widget nextWidget = this->getNextWidgetByIndex(previousWidgetPos);
nextWidget = (Widget*)_children.at(previousWidgetPos);
if (nextWidget->isFocusEnabled()) { if (nextWidget->isFocusEnabled()) {
this->dispatchFocusEvent(current, nextWidget); this->dispatchFocusEvent(current, nextWidget);
@ -1793,8 +1791,7 @@ Widget* Layout::getNextFocusedWidget(FocusDirection dir, Widget *current)
ssize_t previousWidgetPos = _children.getIndex(current); ssize_t previousWidgetPos = _children.getIndex(current);
previousWidgetPos = previousWidgetPos + 1; previousWidgetPos = previousWidgetPos + 1;
if (previousWidgetPos < _children.size()) { if (previousWidgetPos < _children.size()) {
//FIXEDME: find the next avalable widget nextWidget = this->getNextWidgetByIndex(previousWidgetPos);
nextWidget = (Widget*)(_children.at(previousWidgetPos));
//handle widget //handle widget
if (nextWidget) { if (nextWidget) {
if (nextWidget->isFocusEnabled()) { if (nextWidget->isFocusEnabled()) {
@ -1814,7 +1811,6 @@ Widget* Layout::getNextFocusedWidget(FocusDirection dir, Widget *current)
return nextWidget->nextFocusedWidget(dir, nextWidget); return nextWidget->nextFocusedWidget(dir, nextWidget);
} }
} }
//TODO: handle not widget scenaro
else{ else{
return current; return current;
} }
@ -1822,8 +1818,7 @@ Widget* Layout::getNextFocusedWidget(FocusDirection dir, Widget *current)
if (_loopFocus) { if (_loopFocus) {
if (checkFocusEnabledChild()) { if (checkFocusEnabledChild()) {
previousWidgetPos = 0; previousWidgetPos = 0;
//FIXEDME: find the next avalable widget nextWidget = this->getNextWidgetByIndex(previousWidgetPos);
nextWidget = (Widget*)_children.at(previousWidgetPos);
if (nextWidget->isFocusEnabled()) { if (nextWidget->isFocusEnabled()) {
this->dispatchFocusEvent(current, nextWidget); this->dispatchFocusEvent(current, nextWidget);