How to make a fat widget

Moderators: LCMark, LCfraser

Post Reply
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1812
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

How to make a fat widget

Post by [-hh] » Mon Oct 01, 2018 5:17 am

[This is a memo for LCB developers (and for myself). Hopefully it saves some of you some time.]

Finally it is very simple to make a fat widget (avoiding automatic recompilation).
Do the following in the folder of your lcb-file.
  1. Make your lcb file run in both LC 8 and LC 9 (latest stable versions).
  2. Test the lcb-file in LC 8.
    (This generates several other files and module.lcm)
    Close LC 8.
  3. Test the lcb-file in LC 9.
    (This generates several other files, some are overwritten, and module.2.lcm)
    Package the widget in LC 9 (button at bottom left).
You are done, you have a "fat" lce-file, that can via the Extension Manager be imported from either LC 8 or LC 9. The installation is by that done for BOTH, LC 8 and LC 9, in one step.

If you wish to make a sample stack with an installer then add a button (say named "install") with the following script.

Code: Select all

on mouseUp b
  if b=3 then -- set the widget as custom property
    answer file "Locate the *lce* file of the fat LC 8/9 widget"
    if it is empty then exit mouseUp
    set itemdel to slash
    set the widgetLCE of me to item -1 of it
    set itemdel to comma
    put url("binfile:"&it) into f
    set the dateWidget of me to f
  else -- install from the custom property
    set cursor to watch
    put the dateWidget of me into bb
    put the widgetLCE of me into lce
    put the temporary folder & lce into tgt
    put bb into URL("binfile:"& tgt)
    if char 1 of the version is "9" then
      revIDEExtensionInstall tgt, "widget"
    else
      revIDEInstallExtension tgt, "widget"
    end if
    wait 1 second with messages
    delete file tgt
    answer "You have to quit and restart LiveCode now." \
          with "Cancel" or "Quit" as sheet
    if it is "Quit" then quit
  end if
end mouseUp
  • RightClick the button and locate the fat lce-file
    (this puts the file contents into a custom property).
  • SAVE the stack.
  • Click the button to install the fat widget.
  • Restart LiveCode.
For removing the widget add a second button (say named "uninstall") with the following script.

Code: Select all

local wdgt="...." #<-- insert the kind of your widget

on mouseUp b
    if char 1 of the version is "9" then
      revIDEExtensionUninstall wdgt
    else
      revIDEUnInstallExtension wdgt
    end if
    wait 1 second with messages
    answer "" & \
          "Please save the scripts of your widgets before deleting them." &cr& \
          "Then you have to quit and restart LiveCode for a clean work." \
          with "Cancel" or "Quit" as sheet
    if it is "Quit" then quit
end mouseUp
Have fun!

Thanks to Brian Milby for valuable hints to the above and thanks to the team for the great improvements of the Extension Manager and the Extension Builder.
shiftLock happens

Post Reply

Return to “LiveCode Builder”