Page 1 of 1

OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 2:17 am
by JeJe
OOBasic Date Picker dialog

version 25 11 16 (trivial update spelled Calendar wrong in title ha)
version 25 11 16.2 Put in different library as per comments below
version 25 11 16.3 Put in loadlibrary
version 25 11 16.4 Moved mouseover frame to front

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 4:57 am
by RusselB
Why does the .zip file contain a .odt, which is an Open Office Writer file, rather than a .oxt, which is used for extensions and add-ons?

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 12:09 pm
by JeJe
I wrote it for something I'm doing with Writer. You could make it an extension if you want but its intended as use-how-you-want date picker, giving you the basic code for that.

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 1:56 pm
by Villeroy
Any ODF document is a zipped archive already. No need to zip it again.
In order to make the code more accessible, do not distribute the modules in a "Standard" library. Create a lib with a unique name. Then you can use the macro organizer to import the lib into any document or to the global container "My Macros".
Tools>Macros>Organize>Basic...
[Organize ...]
Tab libraries.
Under "Location" select MyMacros or some target document.
[Import...] point to your Date_Picker.ods

The [Export...] button creates a distributable extension (*.oxt, zip archive as well) from a selected non-Standard library.

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 8:09 pm
by JeJe
Thanks for the comments. I've put it in its own library. Its too lame to be an extension on its own. The idea is someone doing some coding might want a date picker as part of their project. I couldn't find one yesterday so made my own.

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 8:33 pm
by Villeroy
JeJe wrote:'ve put it in its own library. Its too lame to be an extension on its own.

Such extension that contains nothing but a Basic library is just a simple way to add and remove Basic code through the extension manager.
There are similar extensions for templates, auto-text, spell check dictionaries. No GUI, no component registration, just put this stuff in the profile folder where it belongs.
If you want the code beeing embedded in a document, call the library organizer select your document and import from the extension file or any document having the library

Re: OOBasic Date Picker dialog

PostPosted: Fri Nov 25, 2016 9:06 pm
by JeJe
Thanks for the info.

Re: OOBasic Date Picker dialog

PostPosted: Thu Aug 10, 2017 1:25 am
by DatFrame
For anyone attempting to use this date picker in their own BASIC code, I have some notes and additions that may be helpful for others:

To incorporate the Picker library into my own collection of Basic libraries I:
- created a new library called "Pickers" and named with module within it "CalM" and then copied and pasted the contents of the "CalM" from JeJe's document into the module I just created.
- exported the "PCalD" dialog from the document into the folder created for my new "Pickers" library. If you have not knowingly changed the location of the libraries in MyMacros, then these will be in the user-specific application data folder, under ".../user/basic/Pickers"
- opened the "PCalD.xdl" file in a text editor and replaced all instances of "location=document" with "location=application", and saved. Doing this will make sure that all event handles (like mouse click events) call the new "Pickers" library instead of the old one in the Writer document.
- imported the "PCalD" dialog I just edited into the the new "Pickers" library

I also made a couple code changes to improve the usability: I changed the DayClick routine so that it does not close the dialog if a blank day was clicked, and have it updating the title of the dialog so that after closing you can check the Title of the dialog to see if it was closed via a date click OR via the close (X) button.
Code: Select all   Expand viewCollapse view
sub DayClick(oEvt) 'day button click
   If oEvt.Source.Text = "" Then
      Exit Sub
   End If
   popUPCal.endexecute
   popUPCal.setTitle("Date Picked")
end sub


Code to check if the dialog was closed with the close button or not:
Code: Select all   Expand viewCollapse view
dDate = ShowDatePicker()
If popUPCal.Title = "Date Picked" Then
    MsgBox "Picker closed upon selecting " & dDate
Else
    MsgBox "Picker closed without selecting a date"
End If