The Problem: Add a "textControl" to a custom control, and place the custom control on a main form (formWindow). set the "ForegroundColor" property of the textControl (I use red in my example below). When the custom control's "generatedInitialize()" predicate is called at startup the application will crash. I believe happens due to the order in which things are initialized.
Here is the example code snippet of the custom control's "generatedInitialize" (last line):
Code: Select all
predicates
generatedInitialize : ().
clauses
generatedInitialize() :-
setText("gameclock"),
setSize(280, 116),
setPaintResponder(onPaint),
gameClockWhite := lcdclock::new(This),
gameClockWhite:setRect(vpiDomains::rct(16, 26, 140, 54)),
gameClockBlack := lcdclock::new(This),
gameClockBlack:setRect(vpiDomains::rct(140, 26, 264, 54)),
whiteColorLabel := textControl::new(This),
whiteColorLabel:setText("WHITE"),
whiteColorLabel:setPosition(16, 6),
whiteColorLabel:setFont(vpi::fontCreateByName("Consolas", 18)),
whiteColorLabel:setSize(124, 20),
whiteColorLabel:setAlignment(vpiDomains::alignCenter),
whiteColorLabel:setForegroundColor(255), % <----------- Setting foreground color to red.
If I manually change the "setForgroundColor" call in "generatedInitialize " (yes, I know you are not supposed to do this, I'm only showing you for example) to the following the problem is averted:
Code: Select all
predicates
generatedInitialize : ().
clauses
generatedInitialize() :-
setText("gameclock"),
setSize(280, 116),
setPaintResponder(onPaint),
gameClockWhite := lcdclock::new(This),
gameClockWhite:setRect(vpiDomains::rct(16, 26, 140, 54)),
gameClockBlack := lcdclock::new(This),
gameClockBlack:setRect(vpiDomains::rct(140, 26, 264, 54)),
whiteColorLabel := textControl::new(This),
whiteColorLabel:setText("WHITE"),
whiteColorLabel:setPosition(16, 6),
whiteColorLabel:setFont(vpi::fontCreateByName("Consolas", 18)),
whiteColorLabel:setSize(124, 20),
whiteColorLabel:setAlignment(vpiDomains::alignCenter),
whenCreated({ :- whiteColorLabel:setForegroundColor(255) }), % <--- for example only (never modify code in the "generatedInitialize" function for those of your reading this!)
%whiteColorLabel:setForegroundColor(255),
I consider this and the secondary observation below to be extremely minor things with regards to my own development. I only report these kinds of issues (like the ZIP file issue) for your tracking system, and help provide you with information, if they turn out to be real issues.
Secondary Observation:
When adding a "textControl" to a main "formWindow" I cannot edit certain properties in the VPC properties editor (like "Font" and "ForegroundColor" because they are not displayed), that I can edit when placed on a "custom control". I mention this because, manually adding the "setForgroundColor(255)" in the "generatedInitialize" function of the "formWindow" does not have the same problem in my application.
Thanks,
choibakk