Custom User Inteface

Typically: "How do I... ", "How can I... " questions
Post Reply
Silvia
Posts: 6
Joined: 02 Jun 2018, 13:54

Custom User Inteface

Post by Silvia »

Hello,
I have a problem while creating a CUI window. In the scene whose link is below, I already use some CUI windows and they work well. The problem is with the ui3: I need this window to be displayed only when an if-condition is satisfied, but in the way I have written the script, the window appears continuously. I have tried to use another kind of loop, like the while or the repeat...until, but I cannot use them in a non-threaded script, and I cannot break the if statement. Could you please help me to find a solution?

Cheers

https://drive.google.com/file/d/13Zk9w- ... sp=sharing

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Custom User Inteface

Post by coppelia »

Hello,

currently you are launching ui3 dialogs in each simulation step (when the if condition is fullfilled).
So you first need to check if that dialog is already open. If not, open it. Otherwise do something else.

E.g. use maybe something like:

Code: Select all

        if not ui3 then
            ui3=simUI.create(xml3)
        end
and

Code: Select all

function closeEventHandler(ui)
    sim.addStatusbarMessage('Window '..ui..' is closing...')
    if ui==ui3 then
        ui3=nil
    end
    simUI.destroy(ui)
end
(do not hide the uis, destroy them instead. Otherwise you can run into tricky situations).

You can also use a modal dialog, if you do not want to user to be able to interact with any other dialog (including V-REP UIs).

Cheers

Post Reply