marat-gainullin / platypus-js

Apache License 2.0
9 stars 9 forks source link

BUG: form.modelGrid.focus(); #71

Closed Level0r0s closed 8 years ago

Level0r0s commented 8 years ago

No set focus to modelGrid.

form.modelGrid.focus();

marat-gainullin commented 8 years ago

Browser's widget ModelGrid is not focusable in nature. The widgets' interface is FAT due to various implementations of Platypus.js UI. There are browser and Java SE Swing widgets with the SAME API.

marat-gainullin commented 8 years ago

ModelGrid is a div element with rich content. So, according to browsers' rules, you can't focus it unless its div have a tabindex attribute. So, try native API: form.modelGrid.element. ...

Level0r0s commented 8 years ago

solved with the function

function TControlerFocus()
       {   this.value = {};   }

var modelGridFocus = new TControlerFocus();

function modelGridFirtsTabStop(el,inicio, o) {
            if (el.tabIndex >-1) {
                   o.value = el;
                   return true;
               }
            else {
                if (!inicio) {
                  // Check if children are tab stops
                   for (var i = 0, l = el.children.length; i < l; i++) {
                        if (modelGridFirtsTabStop(el.children[i],false,o)) {
                            return true;
                        }
                    }
                }    
                else {
                   for (var i = 0, l = el.children.length; i < l; i++) {
                     if (el.children[i].tagName==='TABLE'){
                        if (modelGridFirtsTabStop(el.children[i],false,o)) {
                            return true;
                        }
                     }
                   }
                }
            } 
        } 

------------------------------------------example use

modelGridFirtsTabStop(form.modelGrid.element,true, modelGridFocus) ;
modelGridFocus.value.focus(); 
marat-gainullin commented 8 years ago

Nice work.

marat-gainullin commented 8 years ago

ModelGrid.focus() implemented now as well as onFocusGained and onFocusLost events. Available in nighlty build (on branch master).

Level0r0s commented 8 years ago

green correct ModelGrid.focus() implemented no correct .

now ModelGrid.focus() set to <div class="grid-shel GGTPSL-CC" incorrect red

ModelGrid.focus() set to <td classs="grid-cell grid-td-gwt-uid-32 correct green

example in http://palmsuporte.ddns.com.br:8084

Menu\ Cadastro\Departamento in inputSearch enter text VENDA[enter] use key UP and key DOWN to move in modelgrid use key [ESC] move to inputSearch enter other text COMPRA[enter] ModelGrid.focus() set to First record

marat-gainullin commented 8 years ago

First cell is pretty good, but what if there are no rows in a grid?

Let's consider the following workflow: if grid is empty, entire div element will be focused, if there are cells in scrollable area, first cell of that area will be focused. If not, first cell in one of frozen areas will be focused.

Anyway, we will review your application and its focus related workflow.

Level0r0s commented 8 years ago

my controler TControlerFocus is 100% funcional

marat-gainullin commented 8 years ago

Yes, it is. I mean, we will see, how focus related functionality of our widgets is used in an application.