Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post Reply
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by reinaldocrespo »

Hello everyone;

I hope someone has seen this before. With a dialog from resources when the list box opens on a column inside an xbrowse and an item is highlighted on the listbox, pressing <enter key> to select the item actually closes the dialog. I can't see why as I don't even have a single control on the dialog to close the dialog. I would expect that pressing <enter> on the item would select the item, not close the dialog.

Code: Select all

WITH OBJECT oBrw
   :Concept:nEditType := EDIT_LISTBOX 
   :Concept:aEditListTxt := { 'one', 'two', 'three' }
...
END
 
After opening the listbox and highlighting 'two' on the list, pressing <enter> will simply close the dialog. Again, I don't have any controls on this dialog that will execute a oDlg:End() instruction.

Any ideas?


Reinaldo.
User avatar
gkuhnert
Posts: 274
Joined: Fri Apr 04, 2008 1:25 pm
Location: Aachen - Germany // Kerkrade - Netherlands
Contact:

Re: Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by gkuhnert »

Dear Reinaldo,

do you have a button on the dialog with a flag 'default' set to true? If so, trying to set this to 'false' might help.

Best regards,

Gilbert
Best Regards,

Gilbert Kuhnert
CTO Software GmbH
http://www.ctosoftware.de
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by Rick Lipkin »

Reinaldo

Consider this code from one of my Invoicing apps using xBrowse .. notice the code blocks bEditWhen, bOnPostEdit, and bOnPreEdit

Rick Lipkin

Code: Select all


WITH OBJECT oLbxB
        :lTabLikeExcel := .t.  // allows tab key to toggle between columns
END

oLbxB:lAutoSaves   := .t.
*       oLbxB:lEnterKey2Edit := .f.

// row numbers
ADD oCol to oLbxB AT 1 DATA oLbxB:KeyNo() HEADER 'Ln' size 23 //PICTURE '9999'
oLbxB:aCols[1]:nDataStrAlign := AL_LEFT
oLbxB:aCols[1]:nHeadStrAlign := AL_LEFT


 AEval( oLbxB:aCols, { |o| o:nEditType := EDIT_GET } )

// row number
oLbxB:aCols[1]:nEditType := EDIT_NONE

// qty
oLbxB:aCols[2]:bEditWhen := { || If(oRsDetail:Eof, ,If(oRsDetail:fields("LockedDown"):Value = .f., .t.,.f.)) }
oLbxB:aCols[2]:bOnPostEdit := {|o,v| If(_ChkSerial( v,oRsDetail,oLbxB),;
                         _InvtLook( v, oRsDetail, oRsRepair, "2", oLbxB, @lTaxable,oTaxable, cLoc,;
                         oLabor,oParts,oMisc,oTax,oTotal,cTaxSet,nAssignedTo), ) }

// part number
oLbxB:aCols[3]:bEditWhen   := { || If(oRsDetail:Eof, ,If(oRsDetail:fields("LockedDown"):Value = .f., .t.,.f.)) }
oLbxB:aCols[3]:bOnPostEdit := {|o,v| _InvtLook( v, oRsDetail, oRsRepair, "3", oLbxB, @lTaxable, oTaxable, cLoc,;
                                      oLabor,oParts,oMisc,oTax,oTotal,cTaxSet,nAssignedTo) }

// type
oLbxB:aCols[4]:nEditType    := EDIT_LISTBOX
oLbxB:aCols[4]:aEditListTxt := aType
oLbxB:aCols[4]:bOnPostEdit  := {|o,v| _GetPullDown( v,oLbxB,oRsDetail ) }

// description
oLbxB:aCols[5]:nEditType   := EDIT_GET
        *  oLbxB:aCols[5]:bOnPreEdit  := { || If(oRsDetail:Eof, ,If(oRsDetail:Fields("Item Description"):Value = " ",;
        *                             __Keyboard( Chr( VK_HOME )) ,;
        *                             __Keyboard( Chr( VK_HOME )) )) }
oLbxB:aCols[5]:bOnPostEdit := {|o,v| _GetText( v,oLbxB,oRsDetail ) }

// serial number
ADD oCol to oLbxB AT 6 HEADER 'SerialNo' size 50
oLbxB:aCols[ 6 ]:nEditType  := EDIT_GET_BUTTON
oLbxB:aCols[ 6 ]:bEditBlock := {|row, col, oCol| oLbxB:GoLeftMost(),_SerBrow(;
                       nRepairNumber,;
                       oRsDetail:Fields("Inventory Id"):Value,;
                       oRsDetail:Fields("Qty"):Value,;
                       oRsDetail:Fields("Unique Line"):Value,;
                       oRsDetail,;
                       "","","","","","R","A" ) }  // repair

oLbxB:aCols[ 6 ]:addbmpfile( "zoom2" )
oLbxB:aCols[ 6 ]:addbmpfile( "adddbf" )
oLbxB:aCols[ 6 ]:bBmpData := { | lValue | If( oRsDetail:Fields("IsSerial"):Value = .t., 1, 2 ) }
       *   oLbxB:aCols[ 6 ]:lBtnTransparent := .t.

// labor
ADD oCol to oLbxB AT 7 HEADER '  Labor' size 50     //60
oLbxB:aCols[ 7 ]:nEditType  := EDIT_GET_BUTTON
oLbxB:aCols[ 7 ]:bEditBlock := {|row, col, oCol| ;
                       If(oRsDetail:Fields("Inventory Type"):Value = "Labor",;
                       ( nAmount := _LabrBrow( ;
                       nRepairNumber,;
                       aEmp,;
                       aTech,;
                       oRsDetail,;
                       "","","","","","R","A",oRsDetail:Fields("Unique Line"):Value ),;
                       oRsDetail:Fields("Price"):Value := nAmount,;
                       oRsDetail:Update()), MsgInfo( "Type is not Labor"))   }  // repair

oLbxB:aCols[ 7 ]:addbmpfile( "clockview" )
oLbxB:aCols[ 7 ]:addbmpfile( "clockadd" )
oLbxB:aCols[ 7 ]:bBmpData := { | lValue | If( oRsDetail:Fields("IsLabor"):Value = .t., 1, 2 ) }
   
//  Price
oLbxB:aCols[8]:nEditType := EDIT_GET
oLbxB:aCols[8]:bOnPostEdit := {|o,p| _GetPrice( p,oLbxB,oRsDetail,oRsRepair,lTaxable,oTaxable,;
                                                      oLabor,oParts,oMisc,oTax,oTotal,cTaxSet) }
// extention
ADD oCol TO oLbxB AT 9 DATA {|x| x :=  _CalcExt( oRsDetail:Fields("Qty"):Value,;
                                    oRsDetail:Fields("Price"):Value )} HEADER 'Ext' size 65
oLbxB:aCols[9]:nEditType := EDIT_NONE
oLbxB:aCols[9]:nDataStrAlign := AL_RIGHT
oLbxB:aCols[8]:nHeadStrAlign := AL_RIGHT

// location
oLbxB:aCols[10]:nEditType := EDIT_NONE

// warranty
oLbxB:aCols[11]:nEditType := EDIT_GET
if ! empty(oCol := oLbxB:oCol( "WARRANTY" ))
    oCol:SetCheck( { "ON", "OFF" } )
    oCol:cSortOrder  := nil
endif
 
Image
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by reinaldocrespo »

Hi Rick; I got to tell you; every time I look at one of your screens... I get inspired. Thank you for the screen shot and the code. Forgive me if I steal some of your ideas.

Gilbert- It feels so good to read your response. It bring a smile to my face. I need to come around this forum more often.

I searched for DEFAULT button, but I don't think there is one.

Here is the resource dialog:

Code: Select all

TRANSACTIONS_DLG DIALOG 0, 0, 661, 457
STYLE DS_3DLOOK |DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_VISIBLE |WS_CAPTION 
CAPTION "Property Transactions"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "",1001,"BUTTON",BS_GROUPBOX |WS_CHILD |WS_VISIBLE ,5,432,653,23
  CONTROL "",131,"txbrowse",WS_CHILD |WS_BORDER |WS_VSCROLL |WS_TABSTOP |WS_VISIBLE ,26,19,633,254
  CONTROL "    E&xit",126,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_VISIBLE ,606,438,50,14
  CONTROL "UserDefined",1,"Tfolderex",WS_CHILD |WS_VISIBLE ,5,292,653,141
  CONTROL "    &Print",130,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_VISIBLE ,550,438,50,14
  CONTROL "",99,"COMBOBOX",CBS_DROPDOWNLIST |WS_CHILD |WS_VISIBLE ,59,1,158,12
  CONTROL "Landlord",65535,"STATIC",SS_RIGHT |WS_CHILD |WS_GROUP |WS_VISIBLE ,21,5,33,8
  CONTROL "",97,"COMBOBOX",CBS_DROPDOWNLIST |WS_CHILD |WS_VISIBLE ,265,2,158,12
  CONTROL "Property",65535,"STATIC",SS_RIGHT |WS_CHILD |WS_GROUP |WS_VISIBLE ,228,5,33,8
  CONTROL "",201,"TBtnBmp",WS_CHILD |WS_VISIBLE ,4,19,14,14
  CONTROL "",96,"SysDateTimePick32",WS_CHILD |WS_VISIBLE |0x2,486,3,79,12
  CONTROL "",95,"SysDateTimePick32",WS_CHILD |WS_VISIBLE |0x2,575,3,79,12
  CONTROL "Between",65535,"STATIC",SS_RIGHT |WS_CHILD |WS_GROUP |WS_VISIBLE ,442,5,33,8
  CONTROL "",400,"msctls_progress32",WS_CHILD |WS_VISIBLE ,5,276,653,11
  CONTROL "",202,"TBtnBmp",WS_CHILD |WS_VISIBLE ,4,36,14,14
  CONTROL "",203,"TBtnBmp",WS_CHILD |WS_VISIBLE ,4,53,14,14
  CONTROL "",204,"TBtnBmp",WS_CHILD |WS_VISIBLE ,4,70,14,14
  CONTROL "Net:",500,"STATIC",SS_RIGHT |WS_CHILD |WS_GROUP |WS_VISIBLE ,433,277,220,11
END
 
BTW- pressing <Enter> will not close the dialog unless the EDIT_LISTBOX cell on the xbrowse is highlighting an element on the dropdown list. I would expect pressing <Enter> on an item on the dropdown listbox of the xbrowse cell would pick that item. Instead if closes the dialog. ***BUT*** only if the dialog is non-modal. With a modal dialog pressing <enter> while highlighting an element on the EDIT_LISTBOX of an xbrowse cell produces the expected results.

I would think someone else has seen this behavior before. If not, then I think I will need to create a reduced self-contained sample.

Reinaldo.
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by reinaldocrespo »

Hi everyone;

Here is a reduced-self contained sample that reproduces the explained behavior:

Code: Select all

#include "fivewin.ch"

FUNCTION Main() 
   LOCAL oApp
   
   oApp := TApp():New()

   ACTIVATE WINDOW oApp:oWnd 

RETURN NIL 


//----------------------------------------------------------------------
CLASS TApp 

   DATA oDlg, oWnd, oFld
   DATA oBrw1, oBrw2, oBrw3
   
   METHOD New() 
   METHOD BuildDlg()
   METHOD BuildBrws( oDlg ) 
   
END CLASS


//----------------------------------------------------------------------
METHOD New() CLASS TApp

   DEFINE WINDOW ::oWnd MDI FROM 0, 0 TO MaxRow(), MaxCol() 
   ::oWnd:bInit := { || ::BuildDlg() }

RETURN SELF 


//----------------------------------------------------------------------
METHOD BuildDlg() CLASS TApp

   DEFINE DIALOG ::oDlg RESOURCE "Transactions_Dlg" TRANSPARENT OF ::oWnd ;
      COLOR CLR_BLUE, RGB( 240, 240, 240 )

   REDEFINE FOLDEREX ::oFld OF ::oDlg ID 1 ;
             PROMPTS "Payments", "Charges", "Expenses" ;
             DIALOGS "Fld_Transactions", "Fld_Transactions", "Fld_Transactions"


   ::oBrw1 := ::BuildBrws( ::oFld:aDialogs[ 1 ] )
   ::oBrw2 := ::BuildBrws( ::oFld:aDialogs[ 2 ] )
   ::oBrw3 := ::BuildBrws( ::oFld:aDialogs[ 3 ] )


   ::oDlg:lHelpIcon := .F.

   ACTIVATE DIALOG ::oDlg NOWAIT 


RETURN nil 




//----------------------------------------------------------------------
METHOD BuildBrws( oDlg ) CLASS TApp
   LOCAL aNewData := { Spac(20), CTOD( '' ), 0 }
   LOCAL aConcepts:= { "Rent", "Late Fees", "Legal", "Landscaping", "Other" }
   LOCAL bNew, oBrw
   
   bNew := { || aadd( oBrw:aArrayData, ;
         ACLONE( aNewData ) ),;
         oBrw:Refresh() }


   REDEFINE XBROWSE oBrw  ;
                 ID 99 ;
                 OF oDlg ;
           FASTEDIT AUTOCOLS ;
              ARRAY { ACLONE( aNewData) } ;
             HEADER "Concept", "Date", "Amount";
              SIZES 200, 100, 100 ;
           PICTURES ,,"$999,999.99"


   oBrw:Concept:nEditType := EDIT_LISTBOX
   oBrw:Concept:aEditListTxt := ACLONE( aConcepts )
   oBrw:bPastEof := bNew

RETURN oBrw


 
Here is the resource dialog needed:

Code: Select all

TRANSACTIONS_DLG DIALOG 0, 0, 289, 153
STYLE DS_3DLOOK |DS_SETFONT |DS_MODALFRAME |WS_POPUP |WS_VISIBLE |WS_CAPTION 
CAPTION "Property Transactions"
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "UserDefined",1,"Tfolderex",WS_CHILD |WS_VISIBLE ,5,4,275,141
END
 

Code: Select all

FLD_TRANSACTIONS DIALOG 0, 0, 320, 137
STYLE DS_SETFONT |WS_CHILD |WS_VISIBLE |WS_BORDER 
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "UserDefined",99,"txbrowse",WS_CHILD |WS_BORDER |WS_VSCROLL |WS_TABSTOP |WS_VISIBLE ,6,2,309,130
END
 
Anyone?


Reinaldo.
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Xbrowse + EDIT_LISTBOX <K_ENTER> closes dialog

Post by Rick Lipkin »

Reinaldo

Here is a working sample .. it is not as elegant but you may be able to translate to methods ...

Rick Lipkin

Code: Select all


#include "fivewin.ch"
#Include "xBrowse.Ch"

Static oWind

//---------------------------
Func Main()

Local lOk,nYear

SET DELETED on
SET CENTURY on
SET 3DLOOK on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

// replaces overstrike in gets
Set( _SET_INSERT, .t. )
TGet():lChangeCaret := .f.

lOk := .F.

DEFINE WINDOW oWind                   ;
   FROM 2,2 to 40,120                  ;
   TITLE "xBrowse Listbox Test"       ;
   MENU _BuildMenu()                  ;
   MDI


ACTIVATE WINDOW oWind              ;
   VALID ( IF( !lOK, _ExitPgm(.T.,@lOk ), .F. ))
RETURN NIL


//--------------------------
Static FUNC _BuildMenu()

Local oMenu

MENU oMenu

   MENUITEM "Property Transactions" ;
      ACTION( _BuildDlg(oWind))

   MENUITEM "Quit"                  ;
      ACTION oWIND:END()
   ENDMENU

ENDMENU

Return(oMenu)

//-----------------------
FUNC _ExitPgm( lClean,lOk )

IF lClean = .T.
   lOk := .T.
   SET RESOURCES to
   SysReFresh()
ENDIF

RETURN( lOk )

//------------------------
Static Func _BuildDlg(oWind)

Local cTitle,oWndChild,oFld,oDlg,nFolder
Local aData,aConcepts,oLbx
Local lOk,oCol

lOk    := .f.
cTitle := "Property Transactions"

aData := {}
aadd( aData, { Space(20), ctod("00/00/00"), 0 } )

aConcepts := { "Rent", "Late Fees", "Legal", "Landscaping", "Other" }

DEFINE WINDOW oWndChild              ;
       MDICHILD                      ;
       FROM 2,2 to 25,70             ;
       NOMINIMIZE                    ;
       OF oWind                      ;
       TITLE cTITLE

       oWndChild:bGotFocus = { || oDlg:SetFocus() }

       DEFINE DIALOG oDlg RESOURCE "TRANVIEW" of oWndChild

       REDEFINE FOLDEREX oFld ID 120 of oDlg ;
                PROMPT "Property Transactions";
                DIALOGS "TRANSACT" //;

       //-----------  folder 1
       REDEFINE xBROWSE oLBX             ;
            ARRAY aData                 ;
            COLUMNS 1,2,3               ;
            HEADERS "Concept", "Date", "Amount";
            SIZES 200, 100, 100 ;
            PICTURES ,,"$999,999.99"  ;
            ID 99 of oFld:aDialogs[1]  ;
            AUTOCOLS LINES CELL FASTEDIT

          oLbx:lTabLikeExcel := .t.   // allows tab to move to next fields
          oLbx:nColsel(2)             // starts at col2          
          oLbx:lAutoSaves   := .t.

          // row numbers
          ADD oCol to oLbx AT 1 DATA oLbx:KeyNo() HEADER 'Ln' size 23 //PICTURE '9999'
          oLbx:aCols[1]:nDataStrAlign := AL_LEFT
          oLbx:aCols[1]:nHeadStrAlign := AL_LEFT

          AEval( oLbx:aCols, { |o| o:nEditType := EDIT_GET } )    // set all fields to EDIT_GET
                                                                  // even if fastedit is defined

          // row number
          oLbx:aCols[1]:nEditType := EDIT_NONE

          // type
          oLbx:aCols[2]:nEditType    := EDIT_LISTBOX
          oLbx:aCols[2]:aEditListTxt := aConcepts



       ACTIVATE DIALOG oDLg NOMODAL ;
            ON INIT (oDlg:Move( 0,0 ), .F. ) ;
       VALID(!GETKEYSTATE( 27 ))

ACTIVATE WINDOW oWndChild ;
   ON INIT (oDlg:SetSize( oWndChild:nWidth, oWndChild:nHeight, .t. ),;
           oDlg:refresh(.t.),oLbx:ReFresh(),oLbx:SetFocus());
   VALID ( IIF( !lOK, _ExitPgm(.T.,@lOk), .F. ))


Return(nil)

// end
 
Transact.Rc

Code: Select all

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>

//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
TRANSACT DIALOG 12, 11, 451, 214
STYLE DS_SETFONT | WS_CHILDWINDOW
FONT 6, "MS Sans Serif"
{
    CONTROL         "", 99, "TXBrowse", 0x50B10000, 18, 12, 355, 190, 0x00000000
}
 
Tranview.Rc

Code: Select all

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>

//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
TRANVIEW DIALOG 0, 0, 459, 227
STYLE DS_3DLOOK | DS_SETFONT | WS_VISIBLE | WS_CHILDWINDOW
FONT 8, "MS Sans Serif"
{
    CONTROL         "", 120, "TFolderex", 0x50010000, 21, 8, 335, 210, 0x00000000
}
 
Image
Post Reply