OnPropertyChanged ?

For developers using the Construct 2 Javascript SDK

Post » Wed Dec 28, 2011 10:32 am

I paste a part of a post I wrote few days ago.
I encountered that I guess is a bug...
In edittime.js, in OnPropertyChanged, I compare two properties that makes a change in another property...

if (this.properties["Screen"] == "Low" && this.properties["Orientation"] == "Vertical")
          {
               this.properties["Screen width"] = 320;
               this.properties["Screen height"] = 480;
          }

But, in C2, when I set the property "Screen" to "Low", it doesn't automatically change the "Screen width" value to "320", as it has to do.
I have to input something in the "Screen width" input area, and after that, the value updates automatically to "320"....


septeven2012-01-05 23:58:03
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Wed Dec 28, 2011 4:49 pm

Hmm... does it work if you add RefreshPropertyGrid() after setting the other two properties?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Dec 28, 2011 9:59 pm

@Ashley
It works but popped up me a CheckFailure dialog.
'Refreshing properties bar when in a property changed handler. This is unstable.
Condition: !in_propchanged_handler
File: Bars\PropertiesBar.cpp
Line: 820
Function: void_cdecl CPropertiesBar::Refresh(void)
...'
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Thu Dec 29, 2011 1:13 am

I tried to add RefreshPropertyGrid(); in Draw and it works perfectly...
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Thu Dec 29, 2011 2:05 am

Hmm, you really shouldn't refresh the property grid in Draw, it'll slow down the whole editor... I'll try and fix calling RefreshPropertyGrid from the OnPropertyChanged handler.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Thu Dec 29, 2011 2:18 am

I guessed it. Thanks ashley.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Thu Jan 05, 2012 11:48 pm

First of all, thanks @Ashley for fixed this.
I was wondering how to test only one property changed.
I mean, for the moment, when I put a condition in OnPropertyChanged, it's fired my event each time a property is changed.
I would like that it fires only when one specific property is changed.
Am I clear ?septeven2012-01-05 23:48:27
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sat Jan 07, 2012 5:48 pm

Might I ask again please?
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Sun Jan 08, 2012 6:44 am

@septeven I'm not sure what you mean - OnPropertyChanged is fired once only when a specific property is changed, you filter out the ones you want by comparing the name of the property that was changed.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Sun Jan 08, 2012 1:52 pm

Sorry, I looked for a solution again in other plugins and find the condition with property_name.
Thanks Ashley
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests