Author Topic: ETK: scrolling D2Editor as a member of WScreen?  (Read 5141 times)

0 Members and 1 Guest are viewing this topic.

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
ETK: scrolling D2Editor as a member of WScreen?
« on: January 09, 2014, 02:49:39 pm »
Hello,

I am playing with ETK and I use WScreen to scroll-in a report with some calculation results,
the results are math expressions put to D2Editors so they look nice in 2D representation.

The problem is that everything works as planned in PC software, but not on the handheld (CX CAS, OS 3.2.4)

I don't know if I made it as the ETK author would do it (probably not  ???), but visually it works exactly what I want: the report with
the math expressions scrolls-in and out when triggered via menu or a key press.

What I did basically was:

Code: [Select]
Report = WScreen()

function Report:pushed()
    ...
    self.ed = D2Editor.newRichText()
    self.ed:setReadOnly(true)
    ...
    self.ed:setExpression(<some_string>,1)
    self.ed:setFocus(true)
    ...
end

function Report:paint(gc)
    ...
    self.ed:move(self.x + 5, 24)
    self.ed:resize(self.w - 20, self.h - 0)
    ...
end

It seems like D2Editors are not painted on the handheld at all (inspite move/resize method calls).

What might be the reason for different script behavior in the software/on the handheld?

Thanks and best regards,
Goran

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: ETK: scrolling D2Editor as a member of WScreen?
« Reply #1 on: January 09, 2014, 03:03:16 pm »
Hi,

It looks in fact like what we had done in FormulaPro :)

https://github.com/adriweb/EEPro-for-Nspire/blob/master/EEPro.big.lua#L3976

The difference mainly being that we did the move/resize within postPaint... but I'm not sure if that could be the cause of the no-show on the handheld...
(In fact, I didn't know there was a [bug /] difference of behaviour, for D2Editors, between TINCS and the handheld...

Anyway, I don't even remember why the move/resize was put within postPaint since calling that once should be enough (and there is no paint event that you'd call, the D2Editors are on their own gc, which you don't control, in fact.) - maybe I overlooked something just now when I read the code, and some resizing things needed the move/resize to be called....

Can you confirm that if you create a D2Editor with the same kind of parameters and a dummy text, outside of an ETK widget , it works ?
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
Re: ETK: scrolling D2Editor as a member of WScreen?
« Reply #2 on: January 09, 2014, 03:37:35 pm »
Hello Adriweb,

I did not mentioned in the post: I learn ETK exactly by looking into FormulaPro code.

Regarding putting move/resize calls to either paint() or postPaint() method:
I concluded as you said: it should be irelevant, as it's called just once, either before or after drawing other widgets (if any).
During experimentation, I tried both possibilities anyway, and in the PC software both options work ok and on the handheld neither of them.

Regarding experiment with a D2Editor outside the ETK widget:
What I tried was I made a copy of FormulaPro and embeded a D2Editor into SubCatSel instance of WScreen (in the same way as shown in my previous post).
Again, the D2Editor with a defined simple text scrolled-in together with other widgets in the software, but not on the handheld:
As I defined it in the middle of the screen, in the software it was drawn as a white rectangle over the regular widgets (partially hiding them) with the defined text.
On the handheld all the widgets were regularly visible, no white rectangle with text was hiding them; I conclude that the editor was either not drawn at all or it's drawn first
(even before paint(), as you said we cannot influence on its rendering?)

Does this experiment answer your questions?

Thanks and regards,
Goran

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: ETK: scrolling D2Editor as a member of WScreen?
« Reply #3 on: January 09, 2014, 04:28:22 pm »
What I noticed, too, was that if we used the ful-screen trick, the D2Editors didn't show up on the calculator (fine on TINCS)...
So, if you used that, disable it when you need them :)
If not... I'm out of ideas right now :/

Perhaps Jim Bauwens, for example, can help...
« Last Edit: January 09, 2014, 04:28:53 pm by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: ETK: scrolling D2Editor as a member of WScreen?
« Reply #4 on: January 09, 2014, 04:44:56 pm »
Hmm, pretty strange issue here.
Can you try to 'force' your D2Editor to be visible?

self.ed:setVisible(true)

Also, the gc context you're giving is the current one right? (not saved or generated with platform.withGC/gc).

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
Re: ETK: scrolling D2Editor as a member of WScreen?
« Reply #5 on: January 09, 2014, 05:19:19 pm »
Hello Adriweb,

it works!!!

Your comment on the full-screen trick was crucial:

I just switched the value of doNotDisplayIcon variable from 'false' to 'true'

Code: [Select]
doNotDisplayIcon = true

downloaded to the handheld, and the report just appeared!

I did not look deeper into this part of the code so far (I had originally copy/pasted the ETK portion of the code and I've had intention to disable the icon later),
so I don't get it whats going on, but the important is that the magics work!
(BTW, one thing regarding the icon I've noticed: the icon appears on the handheld, but not in the TINCS, but that fact was not worried me as I had intention to switch it off anyway).

@Jim:

I've just saw your recent contribution to this post and thank you for the care.
I posted this evening another topic regarding "Invalid polar complex" error message
that bother me for days, so if you can help me with this issue, I would appreciate it.

Thanks to both of you,
Goran