AlertWindow : how to change message and close window?

Home Forums General Programming AlertWindow : how to change message and close window?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18507
    Carl Licroy
    Participant
      • Topics: 3
      • Replies: 28
      • Total: 31

      Hi, this is my code for requesting patch names from Prophet08:

      
      -- Create a coroutine in order to wait getting patch name before insertion in table
      GetPatchName = coroutine.create(function()
           for patch_number = 0, 127  do 		
                Receive_request_program_dump(0,patch_number)
                coroutine.yield(x)
                console ("Inserting patch name in table")
                Bank1PatchesTable[patch_number] = PatchName
           end
      end)
      coroutine.resume(GetPatchName)
      

      Everything works fine, but I want to create a message to inform the user about the dump progress and tried this :

      
      DumpProgress = AlertWindow.showMessageBoxAsync(AlertWindow.InfoIcon, "Patch dump", "Patch 0 of 256", "Cancel")
      
      GetPatchName = coroutine.create(function()
           for patch_number = 0, 127  do 		
                Receive_request_program_dump(0,patch_number)
                coroutine.yield(x)
                console ("Inserting patch name in table")
                Bank1PatchesTable[patch_number] = PatchName
                RealPatchNumber = patch_number + 1
                DumpProgress:setMessage("Patch "..RealPatchNumber.." of 256")
           end
           DumpProgress:~AlertWindow()
      end)
      coroutine.resume(GetPatchName)

      SetMessage doesn’t work to change AlertWindow message and compilation failed with the command “~AlertWindow()”. I don’t know how to achieve it… Any help would be very appreciated.

      #18512
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★

        I’ll have a look why AlertWindow is not working (i know it was when i was writing it, but maybe something changed in JUCE and broke it)

        One thing is 100% you can’t call ~AlertWindow(), this is the destructor of that class, all the lifetime of those classes is controlled in C++ or by the Lua’s garbage collector, don’t do that.

        Also this won’t really do what you want, this is all done on one thread (the main GUI thread) so you won’t see any updates in the AlertWindow cause Lua will be blocking it with whatever you are doing, you’d need a new thread or the specialized class in JUCE called (ThreadWithProgressWindow) to do this stuff. It’s not implemented because threading lua and Ctrlr might cause loads of issues.

        I’ll try to figure this out so we can make progress indicators for lengthy operations (this sort of stuff is partially implemented in the new program manager so hopefuly it won’t be needed, but i’ll think about it)

        • This reply was modified 10 years, 2 months ago by atom.
        • This reply was modified 10 years, 2 months ago by atom.
        • This reply was modified 10 years, 2 months ago by atom.
        #18534
        Carl Licroy
        Participant
          • Topics: 3
          • Replies: 28
          • Total: 31

          Thanks Atom, maybe a solution would be to open an AlertWindow for each patch loaded and to close it each time a new patch is loaded. I understand now why I can’t use ~AlertWindow(), is there an other way to programmaticaly close the window (without waiting for user to click “ok”)?

          #18537
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            Well in theory calling exitModalState on the AlertWindow object should make it exit (since AlertWindow is a Component object). But i haven’t tested it yet, i’ll get back to you on that.

            #18538
            atom
            Keymaster
              • Topics: 159
              • Replies: 2945
              • Total: 3104
              • ★★★★★

              I also noticed you are using coroutines, theese are run on different thread. Without locking using different threads will cause unexpected results and crashes all over the place. Please remember that.

              #18873
              Carl Licroy
              Participant
                • Topics: 3
                • Replies: 28
                • Total: 31

                Yes I use coroutines to stop program dump loop until midi message is received and treated by other function. It works well so far.

                I tried to use exitModalState but it doesn’t work. But I finally found a better solution by displaying current loaded patch name and number in the panel lcd display.

              Viewing 6 posts - 1 through 6 (of 6 total)
              • The forum ‘Programming’ is closed to new topics and replies.
              There is currently 0 users and 95 guests online
              No users are currently active
              Forum Statistics
              Threads: 2,495, Posts: 17,374, Members: 77,605
              Most users ever online was 12 on January 22, 2019 3:47 pm
              Ctrlr