Skip to content

Modal issues #142

@ericu

Description

@ericu

I'm having trouble figuring out how to do a modal window from scratch. I think there's at least one API issue, but even with that, it's not working.

First, FL.modal should be returning Ref WindowBase, not Ref Widget. That's an easy fix.
But then when I call it and compare it to my modal window, I get a different pointer back. Am I missing something obvious, and/or is there a more straightforward way to do this than whileM_?

Here's my test code:

showTextEditor :: Text -> IO (Maybe Text)
showTextEditor t = do
  curActive <- FL.modal
  putStrLn $ show ("curActive is ", curActive)
  let size = toSize (300, 200)
  -- TODO: Just Position.
  win <- doubleWindowNew size Nothing (Just "Title")
  setModal win
  buff <- textBufferNew Nothing Nothing
  edit <- textEditorNew (toRectangle (20,20,(300-40),(200-40))) Nothing
  setBuffer edit (Just buff)
  setText buff t
  showWidget win
  let showing = do
        active <- FL.modal
        putStrLn $ show ("showing; active is ", active)
        putStrLn $ show ("showing; win is ", win)
        case active of
          Nothing -> return False
          Just w -> return $ w == (safeCast win)

  putStrLn "Showing"
  whileM_ showing (void FL.wait)
  t' <- getText buff
  putStrLn "Done"

  return $ Just t'

Output:

("curActive is ",Nothing)
Showing
("showing; active is ",Just (Ref 0x00007fa9d0232b30))
("showing; win is ",Ref 0x00007fa9d0204f40)
Done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions