Adding controls to a tab does not add them

Issue #1 closed
Matt Feemster repo owner created an issue
MyGui := Gui()
Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
Tab.UseTab("General")
TabOneEdit := MyGui.Add("Edit", "w200 h200")
MyGui.Show("")

Comments (15)

  1. Matt Feemster reporter

    Please test again.

    The textbox height had nothing to do with tabs. Instead, text boxes are supposed to automatically become multi line if you specify a height or rows.

    Also, I added some code to remove the unsightly dotted selection rectangle on the focused tab.

  2. Winter Laite

    Retested. Works fine if only Edit controls are used. I’m using this code (uncomment 7 & 8 for the version with the bug):

    MyGui := Gui()
    Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
    Tab.UseTab("General")
    GeneralEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    ViewEdit := MyGui.Add("Edit", "w200 h200")
    ;Tab.UseTab("Settings")
    ;SettingsText := MyGui.Add("Text", , "Just hanging around")
    MyGui.Show()
    

  3. Winter Laite

    There is a workaround, but it seems fragile:

    MyGui := Gui()
    Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
    Tab.UseTab("General")
    GeneralEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("Settings")
    SettingsEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    ViewText := MyGui.Add("Text", "w200 h200", "Just hanging around")
    MyGui.Show()
    

    Note the dark background in keysharp, not sure what that means. It does seem that the height is determined in keysharp by the height of the smallest element or an element without width and height params.

  4. Matt Feemster reporter

    I’ve just committed, please try again.

    Although, I worry this commit will always autosize the tab control based on its contents. I don’t think it’ll allow you to override the width and height.

  5. Winter Laite

    Retested with this code:

    MyGui := Gui()
    Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
    Tab.UseTab("General")
    GeneralEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    ViewEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("Settings")
    SettingsText := MyGui.Add("Text", , "Just hanging around")
    Tab.UseTab()
    MyGui.Add("Text", "w200 x10 y+10", "Placeholder for debugging")
    MyGui.Show()
    

    Appears to be working fine! If you don’t mind, I’ll try to throw it a few more curveballs to see if I can break it.

    (BTW, it is easy with 2.0-beta.6&7 to get REALLY unexpected results, and a check of the forums and docs will show that Tab controls have historically presented problems,)

  6. Winter Laite
    MyGui := Gui()
    Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
    Tab.UseTab("General")
    GeneralEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab()
    Hose1 := MyGui.Add("Text", "w200 x10", "Trying to break this.")
    Tab.UseTab("View")
    ViewEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("Settings")
    SettingsText := MyGui.Add("Text", , "Just hanging around")
    Tab.UseTab()
    MyGui.Add("Text", "w200 x10 y+10", "Placeholder for debugging")
    MyGui.Show()
    

    This code does different things in AHK and keysharp. Although I prefer the way keysharp does it, neither is what I expected.

  7. Winter Laite

    On the other hand, the following code gives extremely similar results for AHK and keysharp:

    MyGui := Gui()
    Tab := MyGui.Add("Tab3",, ["General","View","Settings"])
    Tab.UseTab("General")
    GeneralEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    ViewEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("Settings")
    SettingsText := MyGui.Add("Text", , "Just hanging around")
    Tab.UseTab()
    MyGui.Add("Text", "w200 x10 y+10", "Placeholder for debugging")
    Tab.UseTab()
    Hose1 := MyGui.Add("Text", "w200 x10", "Trying to break this.")
    MyGui.Show()
    

  8. Winter Laite

    More tab monkey business. This code gives the varying results shown below it. You can see the background color isn’t honored in keysharp.

    MyGui := Gui()
    Tab := MyGui.AddTab("BackgroundFF9A9A", ["General","View","Settings"])
    Tab.UseTab("General")
    TabOneEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    TabTwoEdit := MyGui.Add("Edit", "w200 h200")
    MyGui.Show()
    

    Keysharp’s autosizing looks better here.

    This code looks better in AHK (sizing is the same as keysharp’s) but still no color in keysharp.

    MyGui := Gui()
    Tab := MyGui.Add("Tab3", "BackgroundFF9A9A", ["General","View","Settings"])
    Tab.UseTab("General")
    TabOneEdit := MyGui.Add("Edit", "w200 h200")
    Tab.UseTab("View")
    TabTwoEdit := MyGui.Add("Edit", "w200 h200")
    MyGui.Show()
    

  9. Matt Feemster reporter

    I’ve committed fixes for the bug where you specify y+10 as well as for the background coloring.

  10. Log in to comment