Author Topic: Toolpalette not working properly  (Read 4650 times)

0 Members and 1 Guest are viewing this topic.

Offline Frog

  • LV2 Member (Next: 40)
  • **
  • Posts: 35
  • Rating: +0/-0
    • View Profile
Toolpalette not working properly
« on: April 28, 2012, 03:57:56 pm »
Hi everyone. It's been some time since I last did something in Lua for the TI-NSpire, but I recently made a script for a school project. It basically uses the default NSpire graph window to draw shapes (circles, hyperbola's, etc.) by parameters. It works great. However, the toolpalette doesn't show when clicking the menu-key, unless you have first opened the calculator using the shortcut. This only happens on the calculator, not in the TI simulator. Really strange behavior, isn't it? I have the following code in my on.create function:

Code: [Select]
menu = {
{"Add",
{"Circle", showForm},
{"Ellipse", showForm},
{"Hyperbola", showForm},
{"Parabola", showForm}
}
}
toolpalette.register(menu)

Am I doing something wrong, or is it just a bug in the OS software?

Thanks!

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
Re: Toolpalette not working properly
« Reply #1 on: April 28, 2012, 05:58:36 pm »
Try putting the code out of any function, at the end of your code for example.
I think toolpalette is defined before the execution of any event, so, as you define it only in the on.create, toolpalette is first defined as "none". And then you define it in the on.create.

Yes toolpalette's behaviour is sometimes weird.
In my translator, the user can change the language, but the menu isn't modified. You have to switch to an other tab to actualize the toolpalette !
Actually, once the toolpalette is set, if you try to change it, you won't see any changes. But if you switch to an other tab (or scratchpad), the toolpalette is defined for this tab, and then when you switch back to your program, the toolpalette is redefined with its last configuration !

That's the explanations I found for this strange behaviour. :)
Don't know if it really works so, though. ^^
« Last Edit: April 28, 2012, 06:02:10 pm by Loulou 54 »
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471

     

Offline Frog

  • LV2 Member (Next: 40)
  • **
  • Posts: 35
  • Rating: +0/-0
    • View Profile
Re: Toolpalette not working properly
« Reply #2 on: April 29, 2012, 11:12:10 am »
That fixed the problem, but it sure is really strange behavior... The more I use the TI Lua API, the more I get the feeling that it is stitched together by some bad tape. For example the D2Editor, or the fact that there is no way to update a graph tab from a Lua tab (a big problem in this app, you have to manually update the graph); it's all weird behavior. Still it's of course better than TI-Basic...

Anyways, thanks a lot for your help! :)

Offline Loulou 54

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 165
  • Rating: +39/-0
    • View Profile
    • Mes programmes sur TI bank.
Re: Toolpalette not working properly
« Reply #3 on: April 29, 2012, 12:12:34 pm »
Fine, you welcome ! :)

Yes the D2Editor could be a very good tool but it has many problem too.. For example I believe we can't disable it. :/
Some of my program available here.. :)
http://ti.bank.free.fr/index.php?mod=archives&ac=voir2&id=1471

     

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Toolpalette not working properly
« Reply #4 on: April 29, 2012, 12:28:40 pm »
Frog, D2Editor is greatly improved in 3.2.
Also, what do mean with updating a graph tab?

Offline Frog

  • LV2 Member (Next: 40)
  • **
  • Posts: 35
  • Rating: +0/-0
    • View Profile
Re: Toolpalette not working properly
« Reply #5 on: April 29, 2012, 03:15:03 pm »
Jim: Great that it has been improved! I tried to use it once, but I couldn't do anything with it. Do you have any clue as to when 3.2 will be released?

In my document I've got one graph tab and one lua tab. In the latter you can create new shapes by parameters in a nice GUI, so for a circle you have to enter parameters a, b and r for example. This data is then used to create a function (or actually two functions, because it's otherwise impossible) that the stock TI graph window can display. These two functions together make up the desired shape.

Since there is no way to add new functions to a graph tab using lua, I've create 20 functions that are all set to 0/0. This means they will be showed when they are set to something else, but will not be displayed until that happens. I then set 2 of these functions to the two functions that I created using the data in lua. What I meant is that there is no way to make this change visible in the graph tab using lua; the graph is only updated when a variable is set in a calculator window or a function is added in the graph tab. The users of my applications have to do that manually, which is not really handy. This must be something that is required quite often? ???

I hope I've made myself clear, since it's quite hard to describe. Do you happen to know a way to do this which I haven't thought of? I need this, because there is no way to display circles, hyperbola's, etc. by parameter in the TI graph window... :-X

Btw, Loulou, your animated signature strangely enough caused both my computer and my iPad to lag... ;)

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Toolpalette not working properly
« Reply #6 on: April 29, 2012, 04:31:53 pm »
Hi,
You can update the G&G graph view through Lua by using var.store or math.eval to update a variable linked to the G&G (for example a point coordinate or a slider control).
« Last Edit: April 29, 2012, 04:32:54 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Toolpalette not working properly
« Reply #7 on: April 29, 2012, 04:44:34 pm »
3.2 should come out soon, how ever I do not know the exact date.
I see your point for the graph stuff. Maybe try to do something like this:
Add a point to the graph where one coordinate is linked to a variable. When updating a graph function change the variable to increment the variable.
This way the point will update, and maybe make that the whole graph screen gets updated.

I'm not sure if it will work, but it's worth a shot.

Offline Frog

  • LV2 Member (Next: 40)
  • **
  • Posts: 35
  • Rating: +0/-0
    • View Profile
Re: Toolpalette not working properly
« Reply #8 on: April 30, 2012, 12:41:29 pm »
Well, that doesn't work either. If I change the variable using math.eval(), it isn't updated in the graph view. No matter whether I use a slider or a function. The only thing that does happen, is that changing a slider value updates the graph. Maybe I can use that to make it slightly easier...

Anyways, thanks for the help!

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Toolpalette not working properly
« Reply #9 on: April 30, 2012, 12:47:42 pm »
I used to force updates by using an animated slider (0-1, inc 1)
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Frog

  • LV2 Member (Next: 40)
  • **
  • Posts: 35
  • Rating: +0/-0
    • View Profile
Re: Toolpalette not working properly
« Reply #10 on: April 30, 2012, 01:16:12 pm »
How come I never think of something like that? Although it does feel a bit hacky, it works the way it should. But why didn't TI just add a Lua command graph.refresh() or something like that? Anyways, thanks a bunch!  :)