Lançado Adianti Framework 7.6!
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.

Pacotão Dominando o Adianti Framework 7
O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado! Versão 7.4


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

Isso mesmo, tem que ficar dentro do construtor.