EditBox without ENTER (CR) chr when press ENTER

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Italia1
Posts: 60
Joined: Mon Mar 24, 2014 10:55 am
Location: Italia

EditBox without ENTER (CR) chr when press ENTER

Post 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
I use the great HMG3.2(stable). Have i nice international HMG to everyone!
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

EditBox without ENTER (CR) chr when press ENTER

Post 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
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Italia1
Posts: 60
Joined: Mon Mar 24, 2014 10:55 am
Location: Italia

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

Post 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
I use the great HMG3.2(stable). Have i nice international HMG to everyone!
User avatar
miszler.zoltan
Posts: 24
Joined: Sun May 26, 2013 12:37 pm
Location: Hungary
Contact:

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

Post by miszler.zoltan »

Gentlemen!

Thanks for the tips!

Sincerely, Zoltan
User avatar
mol
Posts: 3774
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

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

Post by mol »

Works fine, but - if the pressing enter key on BUTTON Control, moves focus to the next control :-)
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

EditBox without ENTER (CR) chr when press ENTER

Post 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.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply