Conheça as melhorias da versão 8.0, 8.1, 8.2!
Clique aqui para saber mais
Retirar evento enter do botão. Olá amigos, gostaria de saber se tem como retirar o evento do enter no botão, pois assim que seleciona um campo e aperta o enter ele realiza o evento do botão. Grato pelo retorno. ...
FV
Retirar evento enter do botão.  
Fechado
Olá amigos, gostaria de saber se tem como retirar o evento do enter no botão, pois assim que seleciona um campo e aperta o enter ele realiza o evento do botão.

Grato pelo retorno.

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (4)


FV

Foi resolvido com jquery, segue o código:

 
  1. <?php
  2. TScript::create('$("input, select, text").keypress(function (e) {var code = null;
  3. code = (e.keyCode ? e.keyCode : e.which);
  4. return (code == 13) ? false : true;
  5. });');
  6. ?>
RC

Onde devemos colocar esse código?
MR

Estou usando o form designer. Coloquei logo abaixo da try {.
 
  1. <?php
  2. /**
  3. * PessoasForm Registration
  4. * @author <your name here>
  5. */
  6. class PessoasForm1 extends TPage
  7. {
  8. private $form;
  9. private $datagrid;
  10. private $pageNavigation;
  11. private $loaded;
  12. /**
  13. * Class constructor
  14. * Creates the page and the registration form
  15. */
  16. function __construct()
  17. {
  18. parent::__construct();
  19. // creates the form
  20. $this->form = new TForm('form_Pessoas');
  21. try
  22. {
  23. TScript::create('$("input, select, text").keypress(function (e) {var code = null;
  24. code = (e.keyCode ? e.keyCode : e.which);
  25. return (code == 13) ? false : true;
  26. });');
  27. // TUIBuilder object
  28. $ui = new TUIBuilder(500,500);
  29. $ui->setController($this);
  30. $ui->setForm($this->form);
  31. // reads the xml form
  32. $ui->parseFile('app/forms/PessoasForm.form.xml');
  33. // get the interface widgets
  34. $fields = $ui->getWidgets();
  35. // look for the TDataGrid object
  36. foreach ($fields as $name => $field)
  37. {
  38. if ($field instanceof TDataGrid)
  39. {
  40. $this->datagrid = $field;
  41. $this->pageNavigation = $this->datagrid->getPageNavigation();
  42. }
  43. }
  44. // add the TUIBuilder panel inside the TForm object
  45. $this->form->add($ui);
  46. // set form fields from interface fields
  47. $this->form->setFields($ui->getFields());
  48. }
  49. catch (Exception $e)
  50. {
  51. new TMessage('error', $e->getMessage());
  52. }
  53. // add the form to the page
  54. parent::add($this->form);
  55. }
  56. /**
  57. * method onSave()
  58. * Executed whenever the user clicks at the save button
  59. */
  60. function onSave()
  61. {
  62. try
  63. {
  64. // open a transaction with database 'sample'
  65. TTransaction::open('sample');
  66. // get the form data into an active record Pessoas
  67. $object = $this->form->getData('Pessoas');
  68. // form validation
  69. $this->form->validate();
  70. // stores the object
  71. $object->store();
  72. // set the data back to the form
  73. $this->form->setData($object);
  74. // close the transaction
  75. TTransaction::close();
  76. // shows the success message
  77. new TMessage('info', TAdiantiCoreTranslator::translate('Record saved'));
  78. // reload the listing
  79. }
  80. catch (Exception $e) // in case of exception
  81. {
  82. // shows the exception error message
  83. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  84. // undo all pending operations
  85. TTransaction::rollback();
  86. }
  87. }
  88. function onEdit($param)
  89. {
  90. try
  91. {
  92. if (isset($param['key']))
  93. {
  94. // get the parameter $key
  95. $key=$param['key'];
  96. // open a transaction with database 'sample'
  97. TTransaction::open('sample');
  98. // instantiates object PessoasTipo
  99. $object = new PessoasTipo($key);
  100. // fill the form with the active record data
  101. $this->form->setData($object);
  102. // close the transaction
  103. TTransaction::close();
  104. }
  105. else
  106. {
  107. $this->form->clear();
  108. }
  109. }
  110. catch (Exception $e) // in case of exception
  111. {
  112. // shows the exception error message
  113. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  114. // undo all pending operations
  115. TTransaction::rollback();
  116. }
  117. }
  118. ?>
</your>
FV

Isso mesmo, tem que ficar dentro do construtor.