Making a Sticky Thread last updated on 2006-07-28 12:37:33

Posted by member 280260 on 2005-12-04 23:14:18

I'm trying to create a "sticky"-type widget for my current theme. For those who haven't seen it on macs, a sticky is just a label with editable text that sits on the desktop.

I've been playing around with xlabel and xtextedit, but xlabel doesn't seem to support multi-line edit boxes and I can't get the reading/writing from the file to work properly.

Any ideas on how to best go about this?

Posted by member 212670 on 2005-12-04 23:46:37 link

It would be pretty easy with xlabel and xtextedit. Just use an editbox and !TexteditBoxExecute/%[textinput]% (with xtext) to write the text to a file. Then the label displaying it would just use "AutoLineBreak" and "AutoHeightMode."

There's also LS Notes, but I've never use that before, so can't say how good it works.

Posted by member 248213 on 2005-12-05 03:25:58 link

man xlabel can do anything :o

cool idea, especially if you can add/subtract as many Stickies as I wanted.

Posted by member 1885 on 2005-12-05 04:26:28 link

I've been thinking about doing something similar myself, but I didn't know xLabel could do it. LSNotes should be avoided, it's old and very buggy. I would like to see a dedicated notes module for LS though, something like sharpNotes (or whatever it's called) in sharpE. There's a similar feature in GeoShell IIRC.

Posted by member 12025 on 2005-12-05 15:14:18 link

xLabel can do it, but it'd be involved (LUA+key codes).

Posted by member 248213 on 2005-12-05 20:57:57 link

/me smells another lock.solid component

smells fruity, and kinda ... tangy ... like ... a weird apple lolly ...

yummy!

Posted by member 280260 on 2005-12-05 21:06:35 link

AutoLineBreak doesn't do anything about editboxes (at least in the build of xlabel I'm using) and as far as I can tell xlabel doesn't have a dedicated evar for storing the text of the editbox. I'm trying to write to my file during OnLoseFocus, but I don't think xlabel allows you to use %[textinput]% in that declaration either (please correct me if I'm wrong on any of these).


What are LUA and key codes?

Posted by member 212670 on 2005-12-05 21:48:21 link

AutoLineBreak doesn't have to do anything with the editbox. Enter the text in the editbox on a single line, write it to a file with "!TexteditBoxExecute editboxlabel !xTextReplace @some file@ @theevar *@ @theevar "%[textinput]%"@". Have the file's text displayed on an label using "(Label)Text "$theevar$", and AutoLineBreak will put it in to multiple lines, depending on the size of the label's width, and the amount of text. And it would be a good idea to use autoheight for the label.

I've never tried this, but I can see no reason why it wouldn't work.

Posted by member 280260 on 2005-12-05 22:36:45 link

Thanks for all your help - works great.

Here's the final code for anyone who's interested:

*Label Sticky

StickyWidth 214
StickyHeight 166
StickyX 641
StickyY 405
StickyImage sticky-bg.png

StickyText "Personal Management Merit Badge!!!"

StickyMoveable
StickyMoveModifierKey ".none"

StickyTextEditBox 5 5 $StickyWidth-10$ #h
StickyAutoLineBreak
StickyAutoHeightMode "center"

StickyBorders 5

StickyFont "Century Gothic"
StickyFontHeight 21

StickyOnLeftClick !Execute [!LabelSetText Sticky ".editbox" "$StickyText$"] [!LabelShow Sticky ".editbox"]
StickyTextEditBoxOnUnfocus !LabelHide Sticky ".editbox"
StickyOnMove !ParseEvars !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^StickyX@ @StickyX %#Stickycurrentx%#@][!xTextReplace @$ConfigDir$sticky.rc@ @^StickyY@ @StickyY %#Stickycurrenty%#@]
StickyTextEditBoxEnterAction !ParseEvars !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^StickyText@ @StickyText "%[textinput]%"@] [!Recycle]

Posted by member 212670 on 2005-12-05 23:57:40 link

Looks good. One suggestion, though. For your editbox's EnterAction, try this instead:
!TexteditBoxExecute editboxlabel !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^StickyText@ @StickyText "%[textinput]%"@][!LabelSetText thetextlabel "%[textinput]%"]

(Change editboxlabel to whatever the label's name is that has the editbox, and changing thetextlabel to whatever label displays the text.)

That way you won't have to !recycle at the end and your label will update its text.

Posted by member 280260 on 2005-12-06 17:40:13 link

I tried doing that and it didn't seem to change it. I'll give it another try.

Posted by member 7204 on 2006-07-28 12:37:33 link

I ran across this just today and using the bit xcal changed it works great. my only problem now is that on !Recycle (using M3 by surazal) the StickyY keeps moving down 39 pixels on its own. any idea whats going on?

edit: eh, nevermind. i set up a hotkey to just reset the sticky x and y