How do I cast Widget to Label in Haskell's GI-Gtk?

后端 未结 1 1184
孤城傲影
孤城傲影 2021-01-28 16:49

I have this sample code where I have a ListBox containing ListBoxRows, which in turn contain a Label. When I click on the ListBox, I get a ListBoxRow. So far so good. The proble

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 17:16

    Try this:

    cc <- containerGetChildren r
    mlabel <- castTo Label (head cc)
    case mlabel of
      Nothing -> putStrLn “Not a label!”
      Just label -> labelGetText label >>= putStrLn
    

    0 讨论(0)
提交回复
热议问题