Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index



On Feb 24, 2013, at 9:32 AM, Andrew Douglas Pitonyak <andrew@pitonyak.org> wrote:


On 02/23/2013 03:24 AM, Hal Vaughan wrote:
I have a macro in LO BASIC that sets up a dialog, then, instead of executing it, I do:

oDialog.setVisible(TRUE)

This dialog box contains a progress bar and, while testing it, I realized it's frustrating for 
longer documents to have a progress bar and force me to sit and wait without a way to cancel it. 
 So I added a Cancel button.

This dialog is in my library and I'd like to find a way to set up the "Cancel" button so it can 
either stop the script or possibly even call a clean up routine when it's been pressed - or have 
it change the state of a global variable so a routine could see if it's been pressed.

I know there are event handlers so I can do something on events like MouseOver and so on.

And if I were not putting this in a library, I could easily specify, in the Dialog Settings, 
which routine to call on Cancel.

But if I want the dialog in a library, is there a way, when calling the function that sets it 
up, to specify a routine to call when the Cancel button is pressed?  Or is there some way to 
create a global variable or any kind of flag that I could have changed when the button is 
pressed?

In other words, other than putting in a "Stop" command, or specifying one routine name to call 
when an event triggers it, can I pass on the name or pointer to a routine that would be called 
when the button is pressed?


Hal
Disclaimer: I have never tried or considered what you desire to do, but..... I suppose that I 
would first test this (should be easy to do).

First, what is it that you are doing that you desire to interrupt? Specifically, is it your macro 
code that is running for a long time, or, did it make a call that is running for a long time? If 
it is your own macro, I would try setting a global in an event handler and check that global in 
your code. You could create a quick test

Basically, interrupt my macro.  It's part of the PDF export page by page I was working on.  Many of 
the documents I want to export would be 90-180 pages.  When exporting a PDF for each page, that can 
take a bit of time.  (Not much - especially for someone who remembers the waits for simple tasks 
back in the 1980s on a computer, but still, enough.)  I have a dialog up with a progress bar so 
there's no long wait wonder what's going on, and it seems wrong to not have a cancel button so, if 
after doing 4-5 pages, the "Oh, crap!  That's not the one I wanted to save that way!" thing pops 
into my head.

while the "cancel requested global is not true" and two minutes has not elapsed
 do something like add zero to a variable

Print "I am out and finished"

Okay - looking up info on this now.  I haven't used globals in LO BASIC yet, but this will work.

Normally I'd just have the cancel button call a specific subroutine, but I'd rather keep it so this 
dialog box and the function to set it up is in a library so I don't duplicate code.

Then, you can check to see if you can set the global variable by clicking on a cancel button and 
having the event handler be called. I am not optimistic that this will work, but, it is worth a 
try. I am very interested in your results.

It'll take me a few days to get to it.  I'll post what would happen.  I would think it'd work - why 
are you not optimistic about it?



Hal
-- 
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.