bitschieber Posted December 1, 2013 Share Posted December 1, 2013 Hello, I need help to program an own component based on TUniEdit (JSObjects.DefaultJSClassName: = 'Ext.form.field.Text' . My questions: 1. How you can access the keypressed event on the Objectmetode e.stopEvent? In the Procedure "LoadCompleted" I initialize the event as follows; JSAddEvent ('keypress', ['eventObj', '%1.nm', 'Key', '%1.charCode'], onkeypress); In Delphi onkeypress Ereigniss I would like to: Params.Values ['eventObj'] access e.stopEvent, how? This works: c: = char (StrToIntDef (string (Params.Values ['key']), 0)); 2. How can I set the maskRe config right? This does not work: JSConfig ('maskRe' ['/ [0-9] /']), or JSConfig ('maskRe', ['new RegExp (/ [0-9] /)']); 3. How to pass 2 parameters with JSProperty: JSProperty ('', [2], 'select text') / / this works and sets the start parameter how can you pass the end parameter? (select text ([start], [end])); Thanks for your help. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 1, 2013 Administrators Share Posted December 1, 2013 e.stopEvent() is a JS function. It can only be accessed on client side. JSConfig('maskRe', [JSStatement('new RegExp("/[0-9]/")')]); JSConfig('maskRe', [JSStatement('/[0-9]/')]); JSCall( 'selectText', [1, 10] ); Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 1, 2013 Administrators Share Posted December 1, 2013 You can try this: JSAddEvent('keypress', ['obj', '%0.nm', 'Key', '%1.charCode'], 'P1.stopEvent()', onkeypress); %0, %1, %2,... are event parameters in function declaration. P0, P1, P2,... are event parameters in auxiliary JS statement. (Which means %0 and P0 are referring to same parameter) Link to comment Share on other sites More sharing options...
bitschieber Posted December 1, 2013 Author Share Posted December 1, 2013 Thank you Farshad, JSCall and JSStatement was the solution. Very helpful, thank you. Link to comment Share on other sites More sharing options...
bitschieber Posted December 1, 2013 Author Share Posted December 1, 2013 Hi Farshad, I do not understand the treatment: "P0, P1, P2, ... are event parameters in JS auxiliary statement." My example: JSAddEvent ('keypress', ['Key', '%1.charCode'], 'P1.stopEvent()', onkeypress); procedure TUniZeit24.OnKeyPress(This: TJSObject; EventName: string; Params: TUniStrings); var c:char; begin c := char(strtointdef(string(Params.Values['Key']),0)); if not (c in ['0','1','2','3','4','5','6','7','8','9','-','+',' ']) then begin // Here i will stop the Keypress Event via stopEvent end; // do something with c end; Thanks Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 1, 2013 Administrators Share Posted December 1, 2013 You can not stop event in Delphi code. Such process must be done in JavaScript code on client side. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted December 1, 2013 Administrators Share Posted December 1, 2013 Maybe something like this: JSAddEvent ('keypress', ['Key', '%1.charCode'], 'if(P1.charCode>='0' && P1.charCode<='9')P1.stopEvent()', onkeypress); Link to comment Share on other sites More sharing options...
bitschieber Posted December 1, 2013 Author Share Posted December 1, 2013 Cheers, now it has made click in my head. I understand it. You've been a great help. I think my questions are answered. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now