8000 修复TabLayout中存在的一处问题 by Iamgublin · Pull Request #156 · duilib/duilib · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

修复TabLayout中存在的一处问题 #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

修复TabLayout中存在的一处问题 #156

wants to merge 1 commit into from

Conversation

Iamgublin
Copy link
@Iamgublin Iamgublin commented Apr 21, 2018

当使用自定义标签初始化TabLayout控件时,如果在同一个Layout控件中使用多个相同的标签:

<TabLayout` height="400" bkcolor="#00000000"  float="false" name="main_switch">
      <HorizontalLayout>
        <Main_Libpath/>
      </HorizontalLayout>
      <HorizontalLayout>
        <Main_Libpath/>
      </HorizontalLayout>
</TabLayout>

在Tab切换的时候,如果从第一个Tab切换为第二个Tab时不会发生问题,第二个Tab切换为第一个会发生
控件消失的问题,这里主要是因为TabLayout控件的SelectItem函数中:

        for (int it = 0; it < m_items.GetSize(); it++)            //从小到大遍历
        {
            if (it == iIndex) {
                GetItemAt(it)->SetVisible(true);                  //(先调用这个)设置Tab=1为显示(EVENT_LOAD_RESOURCE)控件
                GetItemAt(it)->SetFocus();
            }
            else GetItemAt(it)->SetVisible(false);                //(后调用这个)将Tab=2设置为消失,如果it指向的对象相同时(标签相同),就会导致先设置该控件为显示,接着将该控件设置为消失的情况的发生
        }       

Copy link
@gh-orange gh-orange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样更好?

@@ -104,12 +104,16 @@ namespace DuiLib
m_iCurSel = iIndex;
for( int it = 0; it < m_items.GetSize(); it++ )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- for (int it = 0; it < m_items.GetSize(); it++)
- {
-     GetItemAt(it)->SetVisible(false);
- }
- for (int it = 0; it < m_items.GetSize(); it++)
- {
-     if (it == iIndex) {
-     GetItemAt(it)->SetVisible(true);
-     GetItemAt(it)->SetFocus();
-     break;
-     }
- }

+ for (int it = 0; it < m_items.GetSize(); it++)
+     GetItemAt(it)->SetVisible(false);
+ GetItemAt(iIndex)->SetVisible(true);
+ GetItemAt(iIndex)->SetFocus();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

第一次和大佬们零距离接触,exciting😆

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Iamgublin/DuilibTest 点击左上角的按钮即可看到效果

Copy link
Author
@Iamgublin Iamgublin Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了一下你是把return CLoadLibPathInfoUi::Instance();这个改了,你可以试一下以你这个改法,在void MainWindow::OnClick(TNotifyUI & msg)末尾加上

CEditUI* m_pLibPath = static_cast<CEditUI*>(m_PaintManager.FindControl(_T("libpath_path")));
 
m_pLibPath->SetText(L"TEST");

运行以后点击上面的按钮,看看编辑框是否有TEST。

这里CreateControl时候必须以单例返回,,同时对duilib进行本次说明的改动,才能保证编辑框每次切换Tab以后,才能在编辑框中正常的显示TEST字符。

@huanhappy
Copy link
Contributor

我也遇到了这个问题,重用控件时遇到的(多个页显示同一个list, 填充不同的东西)后来解决办法是: tab描述不写重复的,options 切换时控制某个tab显示,之前是1对1,现在是n 对1 就没事了,后来想了想,tab只是一个容器,障眼法,根据option 来显示某tab就可以了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0