|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
event interception on Texthi,
I try to redefine the onkeyPress event onto a Text component for intercepting the keyCode #13 (i.e. for default action when validating a text zone). for this I've implemented an event handler onto the txtObjName object as: txtObjName.keypresshandler.onkeyPress = function () { var keyCode = oThis.txtObjName.keypresshandler.getKeyCode(); if (keyCode != 13) { //default rialto behaviour this.prototype.baseOnkeyPress = rialto.widget.Text.prototype.keypresshandler.onkeyPress; oThis.baseOnkeyPress(); } else //my statements ... } but then I get the error message: rialto.widget.Text.prototype.keypresshandler has no properties and I can't call the herited handler... what the good syntax please for doing this? thx mathieu |
|
|
Re: event interception on TextHello mathieu,
It was almost ok. In fact you don't have to change keypressHandler attribute. As the keypresHandler use the onkeyPress function of the Text widget just redefine it. This function must return a bolean to allow or cancel the keypress Here is an example var myText = new rialto.widget.Text('Text',20,250,350,'A',document.body); myText.baseOnkeyPress=rialto.widget.Text.prototype.checkKeyPress; myText.checkKeyPress=function(){ var keyCode = this.keypresshandler.getKeyCode(); if (keyCode != 13) { //default rialto behaviour return this.baseOnkeyPress(); } else //my statements return true or false } } Cyril --- In rialto-dev@..., "mathieu.cier" <mathieu.cier@...> wrote: > > hi, > > I try to redefine the onkeyPress event onto a Text component for > intercepting the keyCode #13 (i.e. for default action when validating > a text zone). > for this I've implemented an event handler onto the txtObjName object as: > > > txtObjName.keypresshandler.onkeyPress = function () { > var keyCode = oThis.txtObjName.keypresshandler.getKeyCode(); > if (keyCode != 13) { > //default rialto behaviour > this.prototype.baseOnkeyPress = > rialto.widget.Text.prototype.keypresshandler.onkeyPress; > oThis.baseOnkeyPress(); > } > else > //my statements > ... > } > > but then I get the error message: > rialto.widget.Text.prototype.keypresshandler has no properties > > and I can't call the herited handler... > what the good syntax please for doing this? > thx > > mathieu > |
|
|
Re: event interception on Textok thanks a lot. it works fine. mathieu --- In rialto-dev@..., "Cyril Balit" <cbalit@...> wrote: > > Hello mathieu, > > It was almost ok. In fact you don't have to change keypressHandler > attribute. As the keypresHandler use the onkeyPress function of the > Text widget just redefine it. This function must return a bolean to > allow or cancel the keypress > > Here is an example > > var myText = new > myText.baseOnkeyPress=rialto.widget.Text.prototype.checkKeyPress; > myText.checkKeyPress=function(){ > var keyCode = this.keypresshandler.getKeyCode(); > if (keyCode != 13) { > //default rialto behaviour > return this.baseOnkeyPress(); > } > else > //my statements return true or false > } > > } > > Cyril > > > > --- In rialto-dev@..., "mathieu.cier" <mathieu.cier@> > wrote: > > > > hi, > > > > I try to redefine the onkeyPress event onto a Text component for > > intercepting the keyCode #13 (i.e. for default action when validating > > a text zone). > > for this I've implemented an event handler onto the txtObjName > object as: > > > > > > txtObjName.keypresshandler.onkeyPress = function () { > > var keyCode = oThis.txtObjName.keypresshandler.getKeyCode(); > > if (keyCode != 13) { > > //default rialto behaviour > > this.prototype.baseOnkeyPress = > > rialto.widget.Text.prototype.keypresshandler.onkeyPress; > > oThis.baseOnkeyPress(); > > } > > else > > //my statements > > ... > > } > > > > but then I get the error message: > > rialto.widget.Text.prototype.keypresshandler has no properties > > > > and I can't call the herited handler... > > what the good syntax please for doing this? > > thx > > > > mathieu > > > |
| Free Forum Powered by Nabble | Forum Help |