Search code examples
luaiup

Triggering OK from the call back on GetParm


I am using the IUP.GetParm dialog to do a search and replace prompt. The dialog supports 3 buttons, the first two OK and Cancel close the prompt and return to the main program flow.

The third button can be tracked in the parm_action function, what I want to do is use the third button to skip the item and close the dialog, but I can't work out if this is possible.

I have asked this on the IUP mailing list but have not yet had a response.

function param_action(dialog,index)
   if index == -4 then
    bSkip = true
    return 1
   end
end
    bSkip = false
    bConfirm,strFromString,strToString,bSkip = 
    iup.GetParam("Search and Replace", 
    param_action,
    fhGetTag(ptrRecord)..'-'..fhGetTag(ptr)..
    ' '..fhGetDisplayText(ptrRecord).." %t\n"..
    "Replace: "..strBoxType.."\n"..
    "With: "..strBoxType.."\n"..
    "btn: %u[Ok,Cancel,Skip] \n"
    , strFromString,strToString)
    if bConfirm  and not(bSkip) then
       --  replace string
    end

To make this function currently you have to press the Skip button and then the Ok button.


Solution

  • Just re-posting the answer from the IUP mailing list here:

    Inside the call-back, when the 3rd button is pressed, set the dialog attribute "status" to "1" and call the function iup.ExitLoop().