Self-Replicating widget w/o LUA Thread last updated on 2005-12-16 20:38:47

Posted by member 280260 on 2005-12-13 18:44:32

For the theme I'm working on right now, I'm trying to build a widget capable of copying itself - similar to the DeskIcons in Lock.Solid. Based mostly on xLabel, with xTextEdit for the evar saving and copying code. It looks like this so far:
StickyCount 1

*popup "sticky options" !New !PopupSticky
*popup "add sticky" !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^StickyCount@ @StickyCount $StickyCount+1$@][!xTextAppend @$ConfigDir$sticky.rc@ @@][!xTextAppend @$ConfigDir$sticky.rc@ @@][!xTextAppend @$ConfigDir$sticky.rc@ @@][!xTextAppend @$ConfigDir$sticky.rc@ @*Label Sticky$StickyCount+1$@][!xTextAppend @$ConfigDir$sticky.rc@ @Sticky$StickyCount+1$Width 200@][!xTextAppend @$ConfigDir$sticky.rc@ @Sticky$StickyCount+1$Height 200@][!xTextAppend @$ConfigDir$sticky.rc@ @Sticky$StickyCount+1$X 0@][!xTextAppend @$ConfigDir$sticky.rc@ @Sticky$StickyCount+1$Y 0@][!xTextAppend @$ConfigDir$sticky.rc@ @Sticky$StickyCount+1$AddToGroup Sticky@][!xTextAppend @$ConfigDir$sticky.rc@ @@][!Recycle]
*popup ~new

StickyImage sticky.png
StickyAlphaTransparency 190

StickyMoveable
StickyMoveModifierKey ".none"

StickyBorders 5
StickyResizeBorder 3

StickyTextEditBox 5 5 90 #h
StickyAutoLineBreak
StickyAutoMinHeight 100
StickyAutoMinWidth 100

StickyFont "Century Gothic"
StickyFontHeight 21
StickyFontVertAlign "center"
StickyFontAlign "center"

StickyOnRightClick !PopupSticky

;--------------------------------------


*Label Sticky1

Sticky1Width 145
Sticky1Height 131
Sticky1X 70
Sticky1Y 205

Sticky1AddToGroup Sticky
Sticky1Text "Call Rachael!"

Sticky1OnLeftDoubleClick !ParseEvars !Execute [!LabelSetText Sticky1 " "] [!LabelSetText Sticky1 ".editbox" ""] [!LabelShow Sticky1 ".editbox"]
Sticky1TextEditBoxOnUnfocus !LabelHide Sticky1 ".editbox"
Sticky1OnMove !ParseEvars !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^Sticky1X@ @Sticky1X %#Sticky1currentx%#@][!xTextReplace @$ConfigDir$sticky.rc@ @^Sticky1Y@ @Sticky1Y %#Sticky1currenty%#@]
Sticky1TextEditBoxEnterAction !ParseEvars !execute [!xTextReplace @$ConfigDir$sticky.rc@ @^Sticky1Text@ @Sticky1Text "%[textinput]%"@] [!LabelSetText Sticky1 "%[textinput]%"] [!LabelHide Sticky1 ".editbox"]

Sticky1OnResize !ParseEvars !Execute [!xTextReplace @$ConfigDir$sticky.rc@ @^Sticky1Width@ @Sticky1Width %#Sticky1currentwidth%#@] [!xTextReplace @$ConfigDir$sticky.rc@ @^Sticky1Height@ @Sticky1Height %#Sticky1currentheight%#@]


The problem - when I create a new sticky, I have to do an xTextEdit save of xTextEdit commands - I can't stop xTextEdit from parsing the code I'm asking it to write, so it stops halfway through. I've looked at other people building widgets like this and they all seem to use LUA. Is there any other module I can use to do this, or do I have to learn LUA?

Thanks.

Posted by member 248213 on 2005-12-13 20:30:47 link

you need to learn the escape codes for xTextedit.
so %#Sticky1currentheight%# would be something like \%
\#Sticky1currentheight\%\#

or whatever the escape codes are... :p

Posted by member 280260 on 2005-12-14 21:09:40 link

There's no escape character for @ - this doesn't look manageable with xTextEdit.

Posted by member 248213 on 2005-12-14 23:11:04 link

well, the best I can offer is to study lock.solid, and the method I use (including the lua funtion I made: saveevar)

I know it says w/o lua, but still, what your doing is pretty advanced, you may need scripting to make it work.

Posted by member 280260 on 2005-12-14 23:52:10 link

It looks like I may be able to do it by using mzscript to update my variables, but I'm having trouble with the documentation. I guess I'll just look for an article somewhere....

Posted by member 248213 on 2005-12-15 00:11:21 link

best article would be to check out some themes that use mz ;)

good luck man, I cant wait to see the theme you are working on.

Posted by member 280260 on 2005-12-15 23:00:30 link

*doh* - turns out that there was in fact an escape code for @. Probably going to end up using mz anyway because my label creation !execute command is getting monstorously huge.

Posted by member 12025 on 2005-12-16 01:53:02 link

There's also this:
http://wiki.litestep.com/Modules:MZScript
(you can't now, but once the move is complete, feel free to edit!)

Posted by member 280260 on 2005-12-16 20:38:47 link

thanks for the wiki link - should make deleting the labels easier