Re: Event handler method in component

2019-11-11 Thread Jeremy Roussak via 4D_Tech
Chip, you’re right. For my purposes, that isn’t an issue, but your approach is 
perhaps neater.

Jeremy

> On 11 Nov 2019, at 16:43, Chip Scheide <4d_o...@pghrepository.org> wrote:
> 
> Jeremy,
> Just to be clear
> 
> your code will *only* work if both the component and host are 
> interpreted.
> for me, one of the advantages of using a component is being able to 
> compile it.
> 
> For that circumstance you will need to have some other means to inject 
> code.
> as I said I use text files in the resources folder, this is an 
> abbreviated bit of code that runs ON EXIT of the component (when 
> closing development).
> 
> then you can import/inject the code from the component even if the 
> component is compiled. :)
> 
> ARRAY TEXT($Methods;0)
> 
> If (Application type=4D Local mode)
>  //methods to be injected into host system
>  //done this way to allow easy updating of the list
> APPEND TO ARRAY($Methods;)
>  // repeated for each method to export
> 
>  //insure that the most up to date versions of
>  // the methods to be injected are saved to disk
> shtdwn_Write_Code_to_Disk (->$Methods)
> 
> 
> On Mon, 11 Nov 2019 16:16:46 +, Jeremy Roussak wrote:
>> Exactly. FWIW, this is my code. 
> We have done so much, with so little, for so long;
> We are now qualified to anything with nothing 
>  - unknown

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Chip Scheide via 4D_Tech
Jeremy,
Just to be clear

your code will *only* work if both the component and host are 
interpreted.
for me, one of the advantages of using a component is being able to 
compile it.

For that circumstance you will need to have some other means to inject 
code.
as I said I use text files in the resources folder, this is an 
abbreviated bit of code that runs ON EXIT of the component (when 
closing development).

then you can import/inject the code from the component even if the 
component is compiled. :)

ARRAY TEXT($Methods;0)

If (Application type=4D Local mode)
  //methods to be injected into host system
  //done this way to allow easy updating of the list
APPEND TO ARRAY($Methods;)
  // repeated for each method to export

  //insure that the most up to date versions of
  // the methods to be injected are saved to disk
shtdwn_Write_Code_to_Disk (->$Methods)


On Mon, 11 Nov 2019 16:16:46 +, Jeremy Roussak wrote:
> Exactly. FWIW, this is my code. 
We have done so much, with so little, for so long;
We are now qualified to anything with nothing 
  - unknown
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Jeremy Roussak via 4D_Tech
Exactly. FWIW, this is my code. The METHOD SET ATTRIBUTES call allows the 
injected method to be used as a callback. Methods to be injected begin with an 
underscore in the component, which is removed when creating the method in the 
host.

Jeremy

METHOD GET NAMES($omNames;"_OM@")
METHOD GET NAMES($hostNames;"OM@";*)

For ($i;1;Size of array($omNames))

$hostName:=Substring($omNames{$i};2)
If (Find in array($hostNames;$hostName)#-1)  // already exists, 
so see if needs to be updated

METHOD GET MODIFICATION 
DATE($omNames{$i};$omDate;$omTime)
METHOD GET MODIFICATION 
DATE($hostName;$hostDate;$hostTime;*)

If (($omDate>$hostDate) | (($omDate=$hostDate) & 
($omTime>$hostTime)))
METHOD GET CODE($hostName;$code;*)
$hostNameOld:=$hostName+"Old"
METHOD SET CODE($hostNameOld;$code;*)
METHOD GET CODE($omNames{$i};$code)
METHOD SET CODE($hostName;$code;*)
METHOD SET ATTRIBUTE($hostName;Attribute 
shared;True;*)
End if 

Else 

METHOD GET CODE($omNames{$i};$code)
METHOD SET CODE($hostName;$code;*)
METHOD SET ATTRIBUTE($hostName;Attribute shared;True;*)

End if   // if method exists

End for 



> On 11 Nov 2019, at 15:45, Chip Scheide <4d_o...@pghrepository.org> wrote:
> 
> as a bonus you can update the code in the method(s) you are injecting 
> as needs change (or bugs are found and fixed), by simply allowing the 
> injection method to overwrite the existing code.
> 
> Chip
> 
> On Mon, 11 Nov 2019 15:09:34 +, Jeremy Roussak wrote:
>> Chip, you read my mind - that is almost exactly what I implemented 
>> yesterday afternoon. It was really easy to do and it works a treat.
>> 
>> Jeremy
>> 
>>> On 11 Nov 2019, at 15:06, Chip Scheide <4d_o...@pghrepository.org> wrote:
>>> 
>>> another option - depending on your view of doing this... is Code 
>>> injection.
>>> 
>>> At startup of the host (will have to be started at least once 
>>> interpretedly)
>>> you copy the code for the event call method into a method in the host.
>>> 
>>> it looks something like this (interpreted host and component):
>>> METHOD GET CODE() 
>>> METHOD SET CODE(;)
>>> 
>>> Alternatively (compiled component and interpreted host):
>>> - At component shut down, write the method(s) to be injected to disk as 
>>> text (I use the resources folder)
>>> - at host or component startup read the text files
>>> METHOD SET CODE(;)
>>> 
>>> Chip
>>> 
>>> On Sun, 10 Nov 2019 18:07:01 +, Jeremy Roussak via 4D_Tech wrote:
 I’d like to have a method set by ON EVENT CALL to live in a 
 component. It works, in that the method is called on each event, but 
 the system variables Modifiers and KeyCode are undefined so testing 
 for the event itself is tricky.
 
 I can get round the absence of Modifiers by using Macintosh control 
 down, but I’m not sure how I get the keystroke that triggered the 
 event.
 
 Is it possible?
 
 Jeremy
>> 
> We have done so much, with so little, for so long;
> We are now qualified to anything with nothing 
>  - unknown

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Chip Scheide via 4D_Tech
as a bonus you can update the code in the method(s) you are injecting 
as needs change (or bugs are found and fixed), by simply allowing the 
injection method to overwrite the existing code.

Chip
 
On Mon, 11 Nov 2019 15:09:34 +, Jeremy Roussak wrote:
> Chip, you read my mind - that is almost exactly what I implemented 
> yesterday afternoon. It was really easy to do and it works a treat.
> 
> Jeremy
> 
>> On 11 Nov 2019, at 15:06, Chip Scheide <4d_o...@pghrepository.org> wrote:
>> 
>> another option - depending on your view of doing this... is Code 
>> injection.
>> 
>> At startup of the host (will have to be started at least once 
>> interpretedly)
>> you copy the code for the event call method into a method in the host.
>> 
>> it looks something like this (interpreted host and component):
>> METHOD GET CODE() 
>> METHOD SET CODE(;)
>> 
>> Alternatively (compiled component and interpreted host):
>> - At component shut down, write the method(s) to be injected to disk as 
>> text (I use the resources folder)
>> - at host or component startup read the text files
>>  METHOD SET CODE(;)
>> 
>> Chip
>> 
>> On Sun, 10 Nov 2019 18:07:01 +, Jeremy Roussak via 4D_Tech wrote:
>>> I’d like to have a method set by ON EVENT CALL to live in a 
>>> component. It works, in that the method is called on each event, but 
>>> the system variables Modifiers and KeyCode are undefined so testing 
>>> for the event itself is tricky.
>>> 
>>> I can get round the absence of Modifiers by using Macintosh control 
>>> down, but I’m not sure how I get the keystroke that triggered the 
>>> event.
>>> 
>>> Is it possible?
>>> 
>>> Jeremy
> 
We have done so much, with so little, for so long;
We are now qualified to anything with nothing 
  - unknown
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Jeremy Roussak via 4D_Tech
Chip, you read my mind - that is almost exactly what I implemented yesterday 
afternoon. It was really easy to do and it works a treat.

Jeremy

> On 11 Nov 2019, at 15:06, Chip Scheide <4d_o...@pghrepository.org> wrote:
> 
> another option - depending on your view of doing this... is Code 
> injection.
> 
> At startup of the host (will have to be started at least once 
> interpretedly)
> you copy the code for the event call method into a method in the host.
> 
> it looks something like this (interpreted host and component):
> METHOD GET CODE() 
> METHOD SET CODE(;)
> 
> Alternatively (compiled component and interpreted host):
> - At component shut down, write the method(s) to be injected to disk as 
> text (I use the resources folder)
> - at host or component startup read the text files
>  METHOD SET CODE(;)
> 
> Chip
> 
> On Sun, 10 Nov 2019 18:07:01 +, Jeremy Roussak via 4D_Tech wrote:
>> I’d like to have a method set by ON EVENT CALL to live in a 
>> component. It works, in that the method is called on each event, but 
>> the system variables Modifiers and KeyCode are undefined so testing 
>> for the event itself is tricky.
>> 
>> I can get round the absence of Modifiers by using Macintosh control 
>> down, but I’m not sure how I get the keystroke that triggered the 
>> event.
>> 
>> Is it possible?
>> 
>> Jeremy
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Chip Scheide via 4D_Tech
another option - depending on your view of doing this... is Code 
injection.

At startup of the host (will have to be started at least once 
interpretedly)
you copy the code for the event call method into a method in the host.

it looks something like this (interpreted host and component):
 METHOD GET CODE() 
 METHOD SET CODE(;)

Alternatively (compiled component and interpreted host):
- At component shut down, write the method(s) to be injected to disk as 
text (I use the resources folder)
- at host or component startup read the text files
  METHOD SET CODE(;)

Chip

On Sun, 10 Nov 2019 18:07:01 +, Jeremy Roussak via 4D_Tech wrote:
> I’d like to have a method set by ON EVENT CALL to live in a 
> component. It works, in that the method is called on each event, but 
> the system variables Modifiers and KeyCode are undefined so testing 
> for the event itself is tricky.
> 
> I can get round the absence of Modifiers by using Macintosh control 
> down, but I’m not sure how I get the keystroke that triggered the 
> event.
> 
> Is it possible?
> 
> Jeremy
> **
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
We have done so much, with so little, for so long;
We are now qualified to anything with nothing 
  - unknown
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Patrick Emanuel via 4D_Tech
Hi Arnaud,

I had also the same problem and the only way I found is, like all of us, to
insert a method onto the host to call back it.
Not sure that the object is a solution. Nothing found on this and not sure
that another solution exists.

Patrick



-
Patrick EMANUEL

Administrator
www.association-qualisoft.eu 
(Soft1002, Simply Asso & QS_Toolbox)
--
Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-11 Thread Arnaud de Montard via 4D_Tech

> Le 10 nov. 2019 à 19:07, Jeremy Roussak via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> I’d like to have a method set by ON EVENT CALL to live in a component. It 
> works, in that the method is called on each event, but the system variables 
> Modifiers and KeyCode are undefined so testing for the event itself is tricky.
> 
> I can get round the absence of Modifiers by using Macintosh control down, but 
> I’m not sure how I get the keystroke that triggered the event.
> 
> Is it possible?

Hi Jeremy, 
I had a similar problem with an ON ERROR CALL method, after a while I put that 
method back in the host  :-(
Maybe I missed something, like using an object reference in v17… 

-- 
Arnaud de Montard 





**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-10 Thread Jeremy Roussak via 4D_Tech
Thanks, Tim. I thought that was probably the case. 

Jeremy

> On 10 Nov 2019, at 20:22, Tim Nevels via 4D_Tech <4d_tech@lists.4d.com> wrote:
> 
> On Nov 10, 2019, at 2:00 PM, Jeremy Roussak wrote:
> 
>> I’d like to have a method set by ON EVENT CALL to live in a component. It 
>> works, in that the method is called on each event, but the system variables 
>> Modifiers and KeyCode are undefined so testing for the event itself is 
>> tricky.
>> 
>> I can get round the absence of Modifiers by using Macintosh control down, 
>> but I’m not sure how I get the keystroke that triggered the event.
>> 
>> Is it possible?
> 
> No. The variable space for components is separate from the host database. So 
> the process variables “Modifiers” and “KeyCode” only live in the host and are 
> not eve defined in the component environment. Only thing you could do is pass 
> in the values of these variables into a shared method from the component. 
> 
> You still have to call ON EVENT CALL from the host, but from that method on 
> the host it can call a shared component method. Something like this:
> 
> From somewhere in the host you do ON EVENT CALL(“OnEventCallMethod”)
> 
> Host method “OnEventCallMethod”
> 
>  ComponentSharedMethod(Modifiers;KeyCode)
> 
> Tim
**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Event handler method in component

2019-11-10 Thread Tim Nevels via 4D_Tech
On Nov 10, 2019, at 2:00 PM, Jeremy Roussak wrote:

> I’d like to have a method set by ON EVENT CALL to live in a component. It 
> works, in that the method is called on each event, but the system variables 
> Modifiers and KeyCode are undefined so testing for the event itself is tricky.
> 
> I can get round the absence of Modifiers by using Macintosh control down, but 
> I’m not sure how I get the keystroke that triggered the event.
> 
> Is it possible?

No. The variable space for components is separate from the host database. So 
the process variables “Modifiers” and “KeyCode” only live in the host and are 
not eve defined in the component environment. Only thing you could do is pass 
in the values of these variables into a shared method from the component. 

You still have to call ON EVENT CALL from the host, but from that method on the 
host it can call a shared component method. Something like this:

From somewhere in the host you do ON EVENT CALL(“OnEventCallMethod”)

Host method “OnEventCallMethod”

  ComponentSharedMethod(Modifiers;KeyCode)

Tim

*
Tim Nevels
Innovative Solutions
785-749-3444
timnev...@mac.com
*

**
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**