Page 1 of 2

Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 5:28 pm
by sudip
Hello,

I don't know whether it's a bug or not. I found that after editing a cell/row in a grid (especially when CELLNAVIGATION is not used), form became out of focus.

Again, I am telling, I am not sure whether it's a bug or not. :?

Please check this.

With best regards.

Sudip

Re: Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 6:00 pm
by Roberto Lopez
sudip wrote:Hello,

I don't know whether it's a bug or not. I found that after editing a cell/row in a grid (especially when CELLNAVIGATION is not used), form became out of focus.

Again, I am telling, I am not sure whether it's a bug or not. :?

Please check this.

With best regards.

Sudip
I can't verufy that, so, please, if you can post a little sample, could be very useful...

Regards,

Roberto.

Re: Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 7:04 pm
by luisvasquezcl
Lo que comenta sudip es correcto.
Sucede cuando editas la primera vez; al terminar de editar, el grid pierde el foco. Cuando vas a editar nuevamente la fila conserva el foco.
Esto no es nuevo, viene sucediendo desde varias versiones anteriores.

What sudip says is correct.
It happens when editing the first time, to finish editing, the grid loses focus. When you go back to edit the row keeps the focus.
This is not new, been happening since several earlier versions.

Regards,
Luis VAsquez

Re: Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 7:13 pm
by sudip
luisvasquezcl wrote: What sudip says is correct.
It happens when editing the first time, to finish editing, the grid loses focus. When you go back to edit the row keeps the focus.
This is not new, been happening since several earlier versions.
Yes, that is I want to say.
A small sample is :-

Code: Select all

      @ 96, 220 GRID grdCompoundRm ;
         WIDTH 300 ;
         HEIGHT 250 ;
         HEADERS { 'Raw Material', 'Qty', '%' } ;
         WIDTHS { 150, 75, 55 } ;
         COLUMNCONTROLS { { 'COMBOBOX', aRmnm }, ;
         { 'TEXTBOX', 'NUMERIC', '9999.999' }, ;
         { 'TEXTBOX', 'NUMERIC', '999.99%' }} ;
         CELLNAVIGATION ;
         edit ;
	      justify { 0, 1, 1 } ;
	      on LOSTFOCUS calctot() ;
	      COLUMNWHEN { { || .t. }, { || .t. }, { || .f. } }
Roberto, this is not a working sample. If you need I can send you my new project code also. :)

With best regards.

Sudip

Re: Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 10:12 pm
by Roberto Lopez
sudip wrote: Roberto, this is not a working sample. If you need I can send you my new project code also. :)
If you could post a complete small sample, ready to compile, it will help to me a lot.

Regards,

Roberto.

Re: Grid Out of Focus after Edit

Posted: Wed Apr 29, 2009 10:20 pm
by Roberto Lopez
sudip wrote:

Code: Select all

      @ 96, 220 GRID grdCompoundRm ;
         WIDTH 300 ;
         HEIGHT 250 ;
         HEADERS { 'Raw Material', 'Qty', '%' } ;
         WIDTHS { 150, 75, 55 } ;
         COLUMNCONTROLS { { 'COMBOBOX', aRmnm }, ;
         { 'TEXTBOX', 'NUMERIC', '9999.999' }, ;
         { 'TEXTBOX', 'NUMERIC', '999.99%' }} ;
         CELLNAVIGATION ;
         edit ;
	      justify { 0, 1, 1 } ;
	      on LOSTFOCUS calctot() ;
	      COLUMNWHEN { { || .t. }, { || .t. }, { || .f. } }
Your grid definition has references, to a function and an array that are unknown to me. Besides that, the eventual presence of other controls in the window or the window type could be related with the problem, so please post a complete small sample showing the problem, then I'll analyze it.

Thanks in advance.

Regards,

Roberto.

Re: Grid Out of Focus after Edit

Posted: Thu Apr 30, 2009 1:45 am
by sudip
Hello Roberto,

I have found that an out of focus problem occurs after first time edit in Grid in CHILD windows only but not in MODAL or MAIN windows.

(My net has some problems. So I shall post a complete sample after some time)

With best regards.


Sudip

Re: Grid Out of Focus after Edit

Posted: Thu Apr 30, 2009 2:03 am
by sudip
Hello Roberto,

Here is a working sample for the problem. Please run and try to change the "Qty" column of the grid first.

Code: Select all

#include "minigui.ch"

Function Main

   DEFINE WINDOW Win_1 ;
      AT 0,0 ;
      WIDTH 700 ;
      HEIGHT 560 ;
      TITLE 'Grid Edit Problem' ;
      MAIN
   
      DEFINE MAIN MENU
         DEFINE POPUP 'Test'
            MENUITEM 'Test' ACTION GridTest()
         END POPUP
      END MENU

   END WINDOW

   ACTIVATE WINDOW Win_1

Return


Function GridTest()
	
	aRmnm := {"Natural Rubber", "PVC", "Sulphur"}
	
  DEFINE WINDOW frmCompound            ;
      AT 0,0               ;
      WIDTH 635            ;
      HEIGHT 460            ;
      TITLE 'Grid'   ;
      child ;
      ON INIT FillGrid()
      
      
      @ 10, 10 GRID grdCompoundRm ;
         WIDTH 500 ;
         HEIGHT 400 ;
         HEADERS { 'Raw Material', 'Qty', '%' } ;
         WIDTHS { 150, 75, 55 } ;
         COLUMNCONTROLS { { 'COMBOBOX', aRmnm }, ;
         { 'TEXTBOX', 'NUMERIC', '9999.999' }, ;
         { 'TEXTBOX', 'NUMERIC', '999.99%' }} ;
         CELLNAVIGATION ;
         edit ;
	      justify { 0, 1, 1 } ;
	      on LOSTFOCUS calctot() ;
	      COLUMNWHEN { { || .t. }, { || .t. }, { || .f. } }       

	END WINDOW
	
   CENTER WINDOW frmCompound
   ACTIVATE WINDOW frmCompound

   RETURN

   
Function FillGrid()
	local i, aGrid := { {1, 10, 0.00}, {3, 5, 0.00}, {2, 5, 0.00}}
	frmCompound.grdCompoundRm.DeleteAllItems()
	for i = 1 to len( aGrid )
		frmCompound.grdCompoundrm.additem( aGrid[ i ] )
	next
	return nil
	

	
static function CalcTot()
   local a, i, j, aTemp := { }, mTotWt := 0.00
   
   a := frmCompound.grdCompoundRm.value
   i := a[1]
   aTemp := frmCompound.grdCompoundRm.item( i )
   if i < 1
      return
   endif

   for j = 1 to frmCompound.grdCompoundRm.Itemcount
      mTotWt += frmCompound.grdCompoundRm.cell( j, 2 )
   next
   aTemp[ 3 ] := round(aTemp[ 2 ] / iif(empty(mTotWt), 1, mTotWt)*100, 2)
   frmCompound.grdCompoundRm.item( i ) := aTemp
   
   return nil		
Thank you very much. :)

With best regards.

Sudip

Re: Grid Out of Focus after Edit

Posted: Thu Apr 30, 2009 12:35 pm
by Roberto Lopez
sudip wrote:Hello Roberto,

Here is a working sample for the problem. Please run and try to change the "Qty" column of the grid first.

Code: Select all

#include "minigui.ch"

Function Main

   DEFINE WINDOW Win_1 ;
      AT 0,0 ;
      WIDTH 700 ;
      HEIGHT 560 ;
      TITLE 'Grid Edit Problem' ;
      MAIN
   
      DEFINE MAIN MENU
         DEFINE POPUP 'Test'
            MENUITEM 'Test' ACTION GridTest()
         END POPUP
      END MENU

   END WINDOW

   ACTIVATE WINDOW Win_1

Return


Function GridTest()
	
	aRmnm := {"Natural Rubber", "PVC", "Sulphur"}
	
  DEFINE WINDOW frmCompound            ;
      AT 0,0               ;
      WIDTH 635            ;
      HEIGHT 460            ;
      TITLE 'Grid'   ;
      child ;
      ON INIT FillGrid()
      
      
      @ 10, 10 GRID grdCompoundRm ;
         WIDTH 500 ;
         HEIGHT 400 ;
         HEADERS { 'Raw Material', 'Qty', '%' } ;
         WIDTHS { 150, 75, 55 } ;
         COLUMNCONTROLS { { 'COMBOBOX', aRmnm }, ;
         { 'TEXTBOX', 'NUMERIC', '9999.999' }, ;
         { 'TEXTBOX', 'NUMERIC', '999.99%' }} ;
         CELLNAVIGATION ;
         edit ;
	      justify { 0, 1, 1 } ;
	      on LOSTFOCUS calctot() ;
	      COLUMNWHEN { { || .t. }, { || .t. }, { || .f. } }       

	END WINDOW
	
   CENTER WINDOW frmCompound
   ACTIVATE WINDOW frmCompound

   RETURN

   
Function FillGrid()
	local i, aGrid := { {1, 10, 0.00}, {3, 5, 0.00}, {2, 5, 0.00}}
	frmCompound.grdCompoundRm.DeleteAllItems()
	for i = 1 to len( aGrid )
		frmCompound.grdCompoundrm.additem( aGrid[ i ] )
	next
	return nil
	

	
static function CalcTot()
   local a, i, j, aTemp := { }, mTotWt := 0.00
   
   a := frmCompound.grdCompoundRm.value
   i := a[1]
   aTemp := frmCompound.grdCompoundRm.item( i )
   if i < 1
      return
   endif

   for j = 1 to frmCompound.grdCompoundRm.Itemcount
      mTotWt += frmCompound.grdCompoundRm.cell( j, 2 )
   next
   aTemp[ 3 ] := round(aTemp[ 2 ] / iif(empty(mTotWt), 1, mTotWt)*100, 2)
   frmCompound.grdCompoundRm.item( i ) := aTemp
   
   return nil		
Thank you very much. :)

With best regards.

Sudip
Many Thanks!

I'll check it ASAP.

Regards,

Roberto.

Re: Grid Out of Focus after Edit

Posted: Thu Apr 30, 2009 7:59 pm
by Roberto Lopez
sudip wrote:Hello Roberto,

Here is a working sample for the problem. Please run and try to change the "Qty" column of the grid first.
Please add the following line to the end (prior to 'return' line) in '_HMG_GRIDINPLACEEDIT' function ('h_grid.prg' file):

Code: Select all

SETFOCUS ( _HMG_SYSDATA [3] [IDX] ) 
It should solve the problem.

Thanks for the report.

Regards,

Roberto.