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 +0000, 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_to_inject>) >>> METHOD SET CODE(<Source_code>;<Host_New_Method_Name>) >>> >>> 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(<code_from_text_file>;<Host_New_Method_Name>) >>> >>> Chip >>> >>> On Sun, 10 Nov 2019 18:07:01 +0000, 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 <sigh> > - 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 **********************************************************************