fix View::setNextFocusDownId

This commit is contained in:
侯歌 2022-06-13 11:40:01 +08:00
parent b88673806d
commit 19b012cf15
2 changed files with 22 additions and 1 deletions

View File

@ -720,7 +720,7 @@ public:
int getNextFocusUpId()const{return mNextFocusUpId;}
View& setNextFocusUpId(int id){mNextFocusUpId=id;return *this;}
int getNextFocusDownId()const{return mNextFocusDownId;}
View& setNextFocusDownId(int id){mNextFocusUpId=id;return *this;}
View& setNextFocusDownId(int id){mNextFocusDownId=id;return *this;}
int getNextFocusForwardId()const{return mNextFocusForwardId;}
View& setNextFocusForwardId(int id){mNextFocusForwardId=id;return *this;}

View File

@ -38,5 +38,26 @@ TEST_F(KEYNAV,edts){
}
app.exec();
}
TEST_F(KEYNAV,edts1){
App app;
Window*w=new Window(0,0,800,600);
LinearLayout*ll1=new LinearLayout(800,200);
LinearLayout*ll2=new LinearLayout(800,200);
w->addView(ll1);
w->addView(ll2).setPos(0,210);
ll2->setBackgroundColor(0xFF111111);
for(int i=0;i<6;i++){
EditText*tv=new EditText("EditText_"+std::to_string(i)+":"+std::to_string((i+1)%6)+std::to_string((i-1+6)%6),600,50);
tv->setNextFocusDownId((i+1)%6);
tv->setNextFocusUpId((i+5)%6);
if(i<3)ll1->addView(tv).setId(i).setPos(10,10+i*55);
else ll2->addView(tv).setId(i).setPos(10,10+(i-3)*55);
}
View*fv=w->focusSearch(nullptr,View::FOCUS_DOWN);
int loop=0;
while(fv && loop++<=6){
LOGD("focusedview=%p:%d direction=%d \r\n",fv,fv->getId(),View::FOCUS_DOWN);
fv=w->focusSearch(fv,View::FOCUS_DOWN);
}