• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - Skill
  3. Confirm dialog problem before closing a form with 'X'

Stats

  • Replies 5
  • Subscribers 17
  • Views 2428
  • Members are here 0
More Content

Confirm dialog problem before closing a form with 'X'

Arthur Ke
Arthur Ke over 6 years ago

Hi all,

I create a non-block form by axlFormCreate().

I expect that when user click 'x' (right-top side of a form), a window popup and ask if need to save something.

But with my form action function like below, the axlUIYesNo window does not appear and i have no idea why.

procedure( MyFormAct(r_form)

case(r_form->doneState

(3

println("user press X to exit...")
confirm = axlUIYesNo("Do you want to save before exit?" "Test")
println(confirm)

)
(0 println("Do something."))

)

)

command print:
"user press X to exit..."
nil

BTW, SPB version is 17.2-2016 S034

  • Cancel
  • Sign in to reply
  • eDave
    eDave over 6 years ago

    This was fixed in s038

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Arthur Ke
    Arthur Ke over 6 years ago in reply to eDave

    Nice to know about that, many thanks for your instant reply.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Arthur Ke
    Arthur Ke over 6 years ago

    Unfortunately, after update to S048, this problem still exists.
    Below is the complete codes to reproduce the issue: axlUIYesNo() window would be skipped.


    Additionally, if I delete the only button in the form, axlUIYesNo() works again, however, it doesn't help me.


    ;===================================

    procedure( MyGUI()
        prog( (file r_form)
            file = CreateFormFile()
            unless(file printf("\nError: fail to create form file") return(nil))

            r_form = axlFormCreate(gensym() file nil 'FormActions t)
            axlTempFileRemove(file)
            axlFormDisplay(r_form)
        )
    )

    procedure( FormActions(r_form)
        case(r_form->doneState
        (3
            println("user press X to exit...")
            confirm = axlUIYesNo("Do you want to save before exit?" "Test")
            print(confirm)
        )
        (0
            when(equal(r_form->curField "btnTest") println("Do something."))
        )
        )
    )

    procedure( CreateFormFile()
        prog( (formTmpFile fp)
            formTmpFile = axlTempFile()
            fp = outfile(formTmpFile)
            unless(fp return(nil))

            fprintf(fp "FILE_TYPE=FORM_DEFN VERSION=2\n")
            fprintf(fp "FORM FIXED_FONT\n")
            fprintf(fp "FIXED\n")
            fprintf(fp "PORT 38 30\n")
            fprintf(fp "HEADER \"Debug Form\"\n")
            fprintf(fp "TILE\n")

            fprintf(fp "FIELD btnTest\n")
            fprintf(fp "FLOC 1 1\n")
            fprintf(fp "MENUBUTTON \"Test\" 9 3\n")
            fprintf(fp "ENDFIELD\n")

            fprintf(fp "ENDTILE\n")
            fprintf(fp "ENDFORM\n")
            close(fp)
            return(formTmpFile)
        ) ; prog
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 6 years ago in reply to Arthur Ke

    If you run this via an interactive command should work. I tested it using axlCmdRegister("MyGUI" 'MyGUI)

    A button lableled with "cancel" can be used to process the "x".

    Here is a bit of a re-write that you might find useful:

    axlCmdRegister("MyGUI" 'MyGUI)
    procedure( MyGUI()
    prog( (fStr, embFID)
    fStr = CreateFormStr()

    embFID = gensym(); Use this method although it may not be necessary except for miniStatus form.
    r_form = axlFormCreate(embFID, list(sprintf(nil, "embeddedForm_%s", embFID), fStr), nil, 'FormActions, t)

    axlFormDisplay(r_form)
    )
    )

    procedure( FormActions(r_form)
    case(r_form ->curField
    ("btnTest"
    println("Do something.")
    )
    ("cancel"
    println("user pressed Cancel or X to exit...")
    confirm = axlUIYesNo("Do you want to save before exit?" "Test")
    print(confirm)
    axlFinishEnterFun(), axlFormClose(r_form)
    )
    )
    )

    procedure( CreateFormStr()
    list(strcat(
    "FILE_TYPE=FORM_DEFN VERSION=2\n"
    "FORM FIXED_FONT\n"
    "FIXED\n"
    "PORT 38 30\n"
    "HEADER \"Debug Form\"\n"
    "TILE\n"

    "FIELD btnTest\n"
    "FLOC 1 1\n"
    "MENUBUTTON \"Test\" 9 3\n"
    "ENDFIELD\n"

    "FIELD cancel\n"
    "FLOC 11 1\n"
    "MENUBUTTON \"Cancel\" 9 3\n"
    "ENDFIELD\n"

    "ENDTILE\n"
    "ENDFORM\n"
    ))
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Arthur Ke
    Arthur Ke over 6 years ago in reply to eDave

    Thanks, eDave, I got the point. It is not concerned with axlCmdRegister().
    If I add button named 'cancel' and only check the curField equal 'cancel', previous issue could be avoided.

    And I also note the difference between click 'cancel' and click 'x' in this way,
    By clicking 'x', the form will forced to close and this cannot be stopped.
    By clicking 'cancel' button, i can decide if i really want to close form.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information