Skip to content

Commit 674ae4b

Browse files
author
Rodrigo Azevedo
committed
Add propertySet event to Object
1 parent 673861d commit 674ae4b

8 files changed

Lines changed: 16 additions & 5 deletions

File tree

lazarus/lib/x86_64-linux/unit1.o

-16 Bytes
Binary file not shown.

lazarus/lib/x86_64-linux/unit1.ppu

0 Bytes
Binary file not shown.
1.66 KB
Binary file not shown.
0 Bytes
Binary file not shown.

lazarus/phpgui-x86_64-linux

264 Bytes
Binary file not shown.

lazarus/unitipcthread.pas

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ procedure TIpcThread.SetObjectProperty;
429429
propertyValue: Variant;
430430
propInfo: PPropInfo;
431431
subpropertyName: String;
432+
messageId: Integer;
432433
begin
433434
// param[0] = objectId
434435
// param[1] = propertyName
@@ -467,6 +468,9 @@ procedure TIpcThread.SetObjectProperty;
467468
begin
468469
// @TODO: Convert propertyValue to a object checking with PropIsType and GetObjectPropClass
469470
SetPropValue(obj, propertyName, propertyValue);
471+
472+
messageId := jData.FindPath('id').AsInteger;
473+
Output('{"id": ' + IntToStr(messageId) + ',"result": { "propertyName": "' + propertyName + '", "propertyValue": "' + VarToStr(propertyValue) + '"}}');
470474
end;
471475
end;
472476
end;

src/Components/LazarusObjectInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public function getLazarusClass();
2828
* Fire an object event
2929
*
3030
* @param string $eventName Event Name
31+
* @param array $arguments Aguments
3132
*
3233
* @return void
3334
*/
34-
public function fire($eventName);
35+
public function fire($eventName, array $arguments = []);
3536

3637
/**
3738
* Add a listener to an event

src/Components/Object.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,14 @@ protected function set($name, $value)
194194
$name,
195195
$value
196196
],
197-
function ($result) {
198-
// Ok, the property changed
197+
function ($result) use ($name, $value) {
198+
$this->fire(
199+
'onpropertySet',
200+
[
201+
$name,
202+
$value
203+
]
204+
);
199205
}
200206
);
201207
}
@@ -234,11 +240,11 @@ public function getLazarusClass()
234240
/**
235241
* {@inheritdoc}
236242
*/
237-
public function fire($eventName)
243+
public function fire($eventName, array $arguments = [])
238244
{
239245
if (array_key_exists($eventName, $this->eventHandlers)) {
240246
foreach ($this->eventHandlers[$eventName] as $eventHandler) {
241-
$eventHandler();
247+
call_user_func_array($eventHandler, $arguments);
242248
}
243249
}
244250
}

0 commit comments

Comments
 (0)