List Info

Thread: Re: Dialogs: OK button can't call macros?




Re: Dialogs: OK button can't call macros?
user name
2007-01-24 12:32:17
Johnny, the right place for your code (assuming you have modal dialogs) is where you did call dlg.execute(). This will return 0 for Cancel, something else (1) for OK. So if execute() doesn't return 0, do your stuff. Using macros on OK/Cancel button click would be wrong, because users can also use ESC (=cancel) or RETURN (=OK) for closing the dialog. HTH, Malte. Johnny Andersson wrote, On 01/24/07 19:01: > Hi! > > I am writing some StarBasic macros with OpenOffice.org Calc 2.1 on a Windows > XP system. I also created a few dialogs with some fields like date, time, a > combo box, an OK button and a cancel button. > > When creating the button I could set some things in the properties window, > like text on the button, font, size, position and a lot more. I also can set > it to act like one of the following: > > Standard button > OK button > Cancel button > Help button > > I tried different settings, and I realized that one big difference between > the OK setting and the Standard setting, is that when the button is set to > OK mode, the dialog is closed when the button is clicked. Great, that's just > what I want to happen. > > However, I also want some things to happen when the OK button is clicked, in > my case a few cells will be filled in depending on those fields mentioned > earlier, so I assigned the button to a macro that would do the job. I was > rather surprised when I noticed that the macro was never executed so I > thought that maybe I did something wrong, so I changed the button to a > standard button. Now the macro is called and everything works fine, except > that I have to click the cancel button to slose the window. > > So it seems to me that the Cancel button and the OK button does exactly the > same thing, is this true? If so, how is the OK button supposed to be used? > > I guess I can close the dialog with the macro and just let the button be a > standard button, but I still want to know about the OK button: Is this a > bug? Why can I assign the OK button to a macro when it'll never run anyway? > > I am confused... or maybe I just something really stupid or missed something > obvious... > > > > Best regards > > > Johnny > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org For additional commands, e-mail: dev-helpapi.openoffice.org
Re: Dialogs: OK button can't call macros?
user name
2007-01-24 14:32:39
Ok, I think I see what you mean. The difference between the OK button and the Cancel button is that it makes dlg.execute() to return different values. Thanks for pointing that out for me. Now that you say it, it feels like I've been totally blind all the time... *blush* I'll be back with more questions soon... (in another thread of course). Thanks! Johnny 2007/1/24, Malte Timmermann sun.com>: > > Johnny, > > the right place for your code (assuming you have modal dialogs) is where > you did call dlg.execute(). > > This will return 0 for Cancel, something else (1) for OK. > > So if execute() doesn't return 0, do your stuff. > > Using macros on OK/Cancel button click would be wrong, because users can > also use ESC (=cancel) or RETURN (=OK) for closing the dialog. > > HTH, > Malte. > > Johnny Andersson wrote, On 01/24/07 19:01: > > Hi! > > > > I am writing some StarBasic macros with OpenOffice.org Calc 2.1 on a > Windows > > XP system. I also created a few dialogs with some fields like date, > time, a > > combo box, an OK button and a cancel button. > > > > When creating the button I could set some things in the properties > window, > > like text on the button, font, size, position and a lot more. I also can > set > > it to act like one of the following: > > > > Standard button > > OK button > > Cancel button > > Help button > > > > I tried different settings, and I realized that one big difference > between > > the OK setting and the Standard setting, is that when the button is set > to > > OK mode, the dialog is closed when the button is clicked. Great, that's > just > > what I want to happen. > > > > However, I also want some things to happen when the OK button is > clicked, in > > my case a few cells will be filled in depending on those fields > mentioned > > earlier, so I assigned the button to a macro that would do the job. I > was > > rather surprised when I noticed that the macro was never executed so I > > thought that maybe I did something wrong, so I changed the button to a > > standard button. Now the macro is called and everything works fine, > except > > that I have to click the cancel button to slose the window. > > > > So it seems to me that the Cancel button and the OK button does exactly > the > > same thing, is this true? If so, how is the OK button supposed to be > used? > > > > I guess I can close the dialog with the macro and just let the button be > a > > standard button, but I still want to know about the OK button: Is this a > > bug? Why can I assign the OK button to a macro when it'll never run > anyway? > > > > I am confused... or maybe I just something really stupid or missed > something > > obvious... > > > > > > > > Best regards > > > > > > Johnny > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org > For additional commands, e-mail: dev-helpapi.openoffice.org > >
Re: Dialogs: OK button can't call macros?
user name
2007-01-25 00:11:15
Hi again... 2007/1/24, Malte Timmermann sun.com>: > > This will return 0 for Cancel, something else (1) for OK. > > So if execute() doesn't return 0, do your stuff. One thing comes to my mind then: When dlg.execute() is finished (user clicked OK or Cancel), I can "do my stuff", which is to use the data from the dialog, such as date, time and other info that the user selected, isn't that data lost when the dialog is closed? Johnny Using macros on OK/Cancel button click would be wrong, because users can > also use ESC (=cancel) or RETURN (=OK) for closing the dialog. > > HTH, > Malte. > > Johnny Andersson wrote, On 01/24/07 19:01: > > Hi! > > > > I am writing some StarBasic macros with OpenOffice.org Calc 2.1 on a > Windows > > XP system. I also created a few dialogs with some fields like date, > time, a > > combo box, an OK button and a cancel button. > > > > When creating the button I could set some things in the properties > window, > > like text on the button, font, size, position and a lot more. I also can > set > > it to act like one of the following: > > > > Standard button > > OK button > > Cancel button > > Help button > > > > I tried different settings, and I realized that one big difference > between > > the OK setting and the Standard setting, is that when the button is set > to > > OK mode, the dialog is closed when the button is clicked. Great, that's > just > > what I want to happen. > > > > However, I also want some things to happen when the OK button is > clicked, in > > my case a few cells will be filled in depending on those fields > mentioned > > earlier, so I assigned the button to a macro that would do the job. I > was > > rather surprised when I noticed that the macro was never executed so I > > thought that maybe I did something wrong, so I changed the button to a > > standard button. Now the macro is called and everything works fine, > except > > that I have to click the cancel button to slose the window. > > > > So it seems to me that the Cancel button and the OK button does exactly > the > > same thing, is this true? If so, how is the OK button supposed to be > used? > > > > I guess I can close the dialog with the macro and just let the button be > a > > standard button, but I still want to know about the OK button: Is this a > > bug? Why can I assign the OK button to a macro when it'll never run > anyway? > > > > I am confused... or maybe I just something really stupid or missed > something > > obvious... > > > > > > > > Best regards > > > > > > Johnny > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org > For additional commands, e-mail: dev-helpapi.openoffice.org > >
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )