Author Topic: Updating WZGUILib  (Read 156367 times)

0 Members and 3 Guests are viewing this topic.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #120 on: June 29, 2012, 08:23:54 pm »
Even though this is kind of a double post, I think we may have stumbled on to a Ti-Nspire Lua bug...
Say you create a class outside of the string you want to load, or even try to use gc, it will always say that that variable is nil
I even tried this:

********************This is the main lua script
Code: [Select]
ccsb = class()
function ccsb:init(x, y, zs)
    self.x = x
    self.y = y
    self.zs = zs
end
function ccsb:paint(gc)
    local Wself = self
    local Wgc = gc
    loadstring(painter)()
end
---
function loadLibs()
    painter = var.recall("WZEX_lib\\s__paint__")
end
function on.construction()
    ss = ccsb(1, 1, "This is the main string")
    loadLibs()
end
function on.paint(gc)
    ss:paint(gc)
end
function on.charIn(ch)
    platform.window:invalidate()
end
*******************this is inside of the WZEX_lib.tns file
Code: [Select]
"local WZself = Wself
local WZgc = Wgc
WZself.x = WZself.x + 10
WZself.y = WZself.y + 10
WZgc:drawString(WZself.zs, WZself.x, WZself.y, ""top"")"

Even though I tried to use a variable to point to the object as you can see, it is still considered nil inside of the loaded string.
Anything you are not trying to index will be created/modified like normal.
I have attatched the files.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #121 on: July 02, 2012, 02:20:50 pm »
well i got a responce from the TI technical support, a very nice email telling me that Lua scripting is not supported at this time.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Updating WZGUILib
« Reply #122 on: July 02, 2012, 02:52:35 pm »
Lol :P

Can you try to see if making Wself and Wgc global if it works then. Just to see.
Also, it will not be Nspire specific as the class function is just a lua function.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #123 on: July 02, 2012, 03:17:58 pm »
true, I will have to try it and post my results.

EDIT: that works, I wish there was a better way to do it tho...
« Last Edit: July 02, 2012, 03:23:09 pm by jwalker »
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Updating WZGUILib
« Reply #124 on: July 02, 2012, 03:26:15 pm »
Alright, now try to directly  run loadstring in loadlibs.
painter = loadstring(painter).
And then use painter() instead of loadstring everywhere.
It might be because you create a new Lua chunk Lua doesn't allow you to access the local variables there.

Edit: also local the variables again
« Last Edit: July 02, 2012, 03:26:30 pm by jimbauwens »

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #125 on: July 02, 2012, 03:54:32 pm »
It didn't work. The second I make Wgc or Wself local it will give me the 'attempt to index a local 'Wgc/Wself' a nil value' error

EDIT: I changed some code in the WZEX_lib file to this: Wgc:drawString(Wself.zs, Wself.x, Wself.y, "top") and I got an error about indexing Global Wgc, even though there is a local Wgc. It seems to be looking for globals only.
« Last Edit: July 02, 2012, 03:58:33 pm by jwalker »
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Updating WZGUILib
« Reply #126 on: July 02, 2012, 06:21:30 pm »
Try this in the string you load:
local Wself, Wgc=...
And this in your normal code:
painter(self, gc) (painter is loadstrings result)

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #127 on: July 02, 2012, 07:10:15 pm »
that works.
thanks jim
« Last Edit: July 02, 2012, 07:12:52 pm by jwalker »
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Updating WZGUILib
« Reply #128 on: July 03, 2012, 06:48:02 am »
Glad that works. The problem why you can't access the local variables is because the chunk is different from a real function. Another solution would have been to define a function inside the string, and then call that function. But anyway, this is more clean.

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #129 on: July 05, 2012, 11:13:02 pm »
So just a general update.
First I am going to start changing WZGUILIB to use the new lib system.
Second I have started making the 'Programming with WZGUILIB' documentation. It will be written in HTML. I'm using web matrix, but I think as long as I dont do any asp.net stuff it should work on all of the other OS's
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #130 on: July 09, 2012, 08:26:27 pm »
Ive got some bugfixes for you.
I found them in the lable and dialog multiline drawing code.
Here is the file, it shows the work I have done so far, as you can see I have changed the looks of a few controls, mainly I just resized them.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Updating WZGUILib
« Reply #131 on: July 11, 2012, 04:24:57 am »
Tried it, looks nice :)
However, maybe the graphics are a bit too small ?

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #132 on: July 12, 2012, 12:29:12 am »
They are, what Im trying to do is get them just right, so they arent to big, and they arent too small. They have to be just the right size so they can fit in areas other than just forms. I think if I make them just a little bit bigger it might be the right size.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #133 on: July 15, 2012, 12:13:37 pm »
So I had a thought about something that I may do.
I havent realy been able to test out the style system that I proposed, although today I may get Time, but this idea could go hand in hand with it.
What I was thinking about doing was hidding the main events that drive WZ (on.click, on.paint, etc...), and do this instead:
Code: [Select]
  --create a window in on.create, which will still be 'visible' to the user
  window = form(...)
 
  --then after on.create we would have the new 'events'
  window_paint(gc)
  window_click(x, y)--where x and y is the location of the pixel in the forms body
  window_etc.....
all controls would also work similar, so it is kind of like VB.net, or C#.
I thought that this could be released in a WZGUILIB_EventDriven stylepack, or maybe it could be integrated into all WZ versions, although that would be a more radical aproach.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: Updating WZGUILib
« Reply #134 on: July 15, 2012, 05:37:11 pm »
Excuse my double post...
I am happy to announce that I hav successfully got the 'lib' system to work.
Currently, I have only moved the paint code to the lib, but I will move the rest later.
This is a proof of concept release, it is a v3 development version.
I tested these two files on both the computer and my old light blue greyscale nspire.
What this could allow is:
  Easily create styles for WZGUILIB.
  Easily switch styles durring execution.
  Editing how the GUI objects look and work on calc (great for me and style developers).
  Allow multiple styles on one calc without having to have several diffrent versions of WZGUILIB.
  *Allow to only have some class code loaded.

Questions and comments are definately welcome

**********************How to set up**********************
send both files to your calc
place WZ_ST_LIB.tns inot your MyLib folder
Refresh your libraries
execute WZ_LibTST

*I havnt yet implemented it.
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads