Page 1 of 1

EditBox without ENTER (CR) chr when press ENTER

Posted: Fri May 09, 2014 2:15 pm
by Italia1
Hello to everyone! :)

I have an EditBox (800 chars). When i put ENTER key i don't want chr(13) in EditBox. I must STRTRAN(EditBoxName,chr(13)," ") or there are another method?
I would like when press ENTER key do same action of the tab key (next field in window).
Thank to all!
Bye. :P

EditBox without ENTER (CR) chr when press ENTER

Posted: Fri May 09, 2014 2:38 pm
by Pablo César
Hi italian,

This seems could be useful for you:

Code: Select all

#include "hmg.ch"

Function Main
DEFINE WINDOW Form_1 ;
    AT 0,0 ;
    WIDTH 450 HEIGHT 340 ;
    TITLE 'HMG EditBox Demo' ;
    MAIN
	
	ON KEY RETURN ACTION _SetNextFocus()
	ON KEY ESCAPE ACTION ThisWindow.Release()

    DEFINE STATUSBAR
        STATUSITEM 'HMG Power Ready!' 
    END STATUSBAR

    @ 30,10 EDITBOX Edit_1 ;
        WIDTH 410 ;
        HEIGHT 140 ;
        VALUE 'EditBox!!' ;
        TOOLTIP 'EditBox' ;
        MAXLENGTH 255
        
    DEFINE TEXTBOX Text_1
        ROW    180
        COL    130
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
    END TEXTBOX
	
	DEFINE TEXTBOX Text_2
        ROW    220
        COL    130
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
    END TEXTBOX

END WINDOW
Form_1.Center()
Form_1.Activate()
Return Nil

Re: EditBox without ENTER (CR) chr when press ENTER

Posted: Fri May 09, 2014 2:57 pm
by Italia1
Great Pablo César :D !!

ON KEY RETURN ACTION _SetNextFocus() is the perfect solution!

http://hmgforum.com/hmgdoc/data/onkey.htm

Thanks very very much!

:D

Re: EditBox without ENTER (CR) chr when press ENTER

Posted: Mon May 12, 2014 9:04 am
by miszler.zoltan
Gentlemen!

Thanks for the tips!

Sincerely, Zoltan

Re: EditBox without ENTER (CR) chr when press ENTER

Posted: Mon May 12, 2014 9:19 am
by mol
Works fine, but - if the pressing enter key on BUTTON Control, moves focus to the next control :-)

EditBox without ENTER (CR) chr when press ENTER

Posted: Mon May 12, 2014 11:28 am
by Pablo César
miszler.zoltan wrote:Gentlemen!

Thanks for the tips!

Sincerely, Zoltan
You are welcomed ! :)

mol wrote:Works fine, but - if the pressing enter key on BUTTON Control, moves focus to the next control :-)
Yes sure ! This is normal, but this can also be implemented an exception for other types.

Code: Select all

#include "hmg.ch"

Function Main
DEFINE WINDOW Form_1 ;
    AT 0,0 ;
    WIDTH 450 HEIGHT 340 ;
    TITLE 'HMG EditBox Demo' ;
    MAIN
	
	ON KEY RETURN ACTION OnlyForEditBox()
	ON KEY ESCAPE ACTION ThisWindow.Release()

    DEFINE STATUSBAR
        STATUSITEM 'HMG Power Ready!' 
    END STATUSBAR

    @ 30,10 EDITBOX Edit_1 ;
        WIDTH 410 ;
        HEIGHT 140 ;
        VALUE 'EditBox!!' ;
        TOOLTIP 'EditBox' ;
        MAXLENGTH 255
        
    DEFINE TEXTBOX Text_1
        ROW    180
        COL    130
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
    END TEXTBOX
	
	DEFINE TEXTBOX Text_2
        ROW    220
        COL    130
        WIDTH  120
        HEIGHT 24
        FONTNAME "Arial"
        FONTSIZE 9
    END TEXTBOX

END WINDOW
Form_1.Center()
Form_1.Activate()
Return Nil

Function OnlyForEditBox()
Local cContType := GetFocusedControlType()

If cContType == "EDIT"
   _SetNextFocus()
Else
   DoMethod("Form_1","Edit_1","SetFocus")
Endif
Return Nil
And if you do not want to back to EditBox, remove SetFocus line.