We are about to switch to a new forum software. Until then we have removed the registration on this forum.
http://www.lagers.org.uk/g4p/ref/classg4p__controls_1_1_g_window.html
After reading the reference for GWindow, it appears that there is no access to GWindow.settings() or GWindow.setup()
What is the correct approach to drawing only when required?
Answers
This sketch demonstrates one way to do what you want. Click the mouse on the main sketch window and the second window is updated.
Interesting. That sketch you posted has raised some specific questions. This is the first time I'm using your library so my apologies if some are answered elsewhere.
Question 1:
Question 2:
data is unused object, yet floats are updated.
This is different than everything I've read so far for how the data is distributed, like:
Ok to answer your questions.
Q1 The noLoop / loop in the setup method were added by GUI Builder. It fixes a problem when large numbers of G4P controls are added to the GWindow. In this case these statements can be deleted.
The noLoop must be put somewhere, by putting it at the end of the draw method it will stop the window looping from the start. On the main sketch window you would put it in setup but GWindow does not support settings or setup because a sketch only has one of each.
Q2 the GWindow draw and event handlers can access any global variable. The data object is optional, it allows each GWindow to have its own data. The choice is yours.
Alright, everything makes sense to me now. Thank you very much quark! :-bd
So this noLoop thing is still looping once.
Prints:
Is the easiest fix to just have a boolean runOnce if condition?
Am I missing something?
Yes but is normal behaviour for Processing. Try this sketch and you see it always loops once.
The easiest solution is too check the frame count like this
Applying this and my previous comments to my example above we get
Oh wow that's much easier than a boolean. Derp.
So you've completely solved my problem, but I just want to be thorough about what I'm saying what my problem here is.
Prints:
B cycles twice using the same logic as main draw. That's confusing, that's all and nothing more.
I am really enjoying this library. Thank you for your support and making it, Mr. quark. :)
What is interesting is that the
frameCount
is not incremented even thoughwin_draw1()
has been executed twice. I'll be honest I don't no why that is :\"> I would need to investigate further.It does not detract from the solution which is logically correct :)
Thank you for your assistance, it has been literally invaluable.