Calculator Community > Lua

ETK: scrolling D2Editor as a member of WScreen?

(1/2) > >>

Goran:
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: ---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

--- End code ---

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

Adriweb:
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 ?

Goran:
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

Adriweb:
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...

Jim Bauwens:
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).

Navigation

[0] Message Index

[#] Next page

Go to full version