AskClose() in GeModalDialog()



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/04/2006 at 04:37, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R9.5 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;

    ---------
    Hello,

    the C.O.F.F.E.E. SDK documentation states in the description of GeModalDialog:
    "Note: If the user hits the OK button, AskClose() is called automatically before the dialog is closed. So if one wants to make additional error checks before closing the dialog one gets the time to do so there."

    I've programmed a plugin with calling a modal dialog, but the AskClose() function is called also if the user hits the CANCEL button! Is there a chance to fix that?

    Juergen



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/04/2006 at 05:24, xxxxxxxx wrote:

    Hi again ...

    I have a problem with the

    GeModalDialog
    

    implementation: when I overload the

    AskClose()
    

    function, this function is called twice when the dialog is closed!

    I have created a simple menu-plugin to call a modal dialog with only static text and OK/CANCEL buttons. The

    AskClose()
    

    function simply prints a line into the console ...
    When CANCEL is clicked, one line is printed ->

    AskClose()
    

    is called once.
    When OK is clicked, the line is printed twice ->

    AskClose()
    

    is called twice.

    Any helpful ideas? Is this a bug in the C4D code?
    (I can post my code here if that helps ... )

    Thanks,
    Juergen



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 13/04/2006 at 06:47, xxxxxxxx wrote:

    does this matter? Also depends on your plugin. Maybe it is caused by another function or whatever. Without any code, it´s nearly impossible to say anything.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2006 at 02:13, xxxxxxxx wrote:

    Hi again,
    it does matter, because:
    1. I want to check for input errors only on "OK". I could do that with the

    GetResult()
    

    also in the

    AskClose()
    

    function, but I thought there would be a way of "clean" programming.
    2. I want to create an object depending on the input of the GUI. I would do that in

    AskClose()
    

    , but then the object is created twice, since the function is called twice.

    Here is the simple example (sorry for the long post) :

      
    //dummy.cof  
      
    const var PlugID_dummy = 1000008;  
    var dummy_resource;  
      
    include "c4d_symbols.h"  
      
    class dummy_dialog : GeModalDialog  
    {  
         public:  
              dummy_dialog();  
              CreateLayout();  
              Command(id, msg);  
         private:  
              AskClose();  
      
    }  
      
    dummy_dialog::dummy_dialog()  
    {  
         super();  
    }  
      
    dummy_dialog::CreateLayout()  
    {  
        return(LoadDialogResource(dummy_layout, dummy_resource, 0));  
    }  
      
    dummy_dialog::Command(id, msg)  
    {  
         return TRUE;  
    }  
      
    dummy_dialog::AskClose()  
    {  
         println("Calling AskClose().");  
         return FALSE;  
    }  
      
    class dummy_menu : MenuPlugin  
    {  
         public:  
              dummy_menu();  
              GetID();  
              GetName();  
              GetHelp();  
              Execute(doc);  
         private:  
              var dialog;  
    }  
      
    dummy_menu::dummy_menu()  
    {  
         super();  
         dialog = 0;  
    }  
      
    dummy_menu::GetID() { return PlugID_dummy; }  
    dummy_menu::GetName() { return "Dummy Menu"; }  
    dummy_menu::GetHelp() { return "just a test"; }            
      
    dummy_menu::Execute(doc)  
    {  
         dialog = new(dummy_dialog);  
         dialog->Open( -1, -1);  
         return TRUE;  
    }  
      
    main()  
    {  
         var root = GeGetRootFilename();  
         root->RemoveLast();  
         dummy_resource = new(GeResource, root);  
      
         Register(dummy_menu);  
         println("dummy loaded.");  
    }  
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2006 at 02:27, xxxxxxxx wrote:

    Hi,

    1. gui messages are caught in the command function! You should also be able to process/create your object once the user hits ok. (AskClose isn´t the right function)

    2. If you still want to create your object in the AskClose function (for whatever reason), use a Singleton (see the internet for a description). This makes sure that only one pointer of the object is available, no matter how often a function is called. A simple increment member variable would surely also do it.

    HTH
    Katachi



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2006 at 07:50, xxxxxxxx wrote:

    Hi,
    thanks Katachi for the reply.

    ad 1. if I use a GeModalDialog the OK-button is not caught in the command function. That's why I'm using AskClose().

    ad 2. The increment sure does it, however this is still not a very "clean" solution. I might as well just use the more general GeDialog and handle the OK/CANCEL buttons myself.

    Cheers, Juergen



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/04/2006 at 07:55, xxxxxxxx wrote:

    oops, sorry, I was assuming that we were talking about a GeDialog implementation. I should read more carefully :) So, all I said was according to a GeDialog concept.


Log in to reply