Uppercase in textbox (HMG4)
Moderator: Rathinagiri
Uppercase in textbox (HMG4)
Hi Friends, how to convert characters to uppercase in textbox?
Re: Uppercase in textbox (HMG4)
Friends, to decide the problem with CaseConvert and MaxLength, I modified the file textbox.prg:
// Internal Data
I do not know if it is the best solution, but it gave certain!
Samples:
// Internal Data
Code: Select all
DATA nMaxLength INIT 0
Code: Select all
METHOD MaxLength( nValue ) CLASS TEXTBOX
IF PCOUNT() == 0
RETURN ::nValue
ELSEIF PCOUNT() == 1
::nMaxLength := nValue
ENDIF
RETURN NIL
Code: Select all
METHOD CASEConvert( nValue ) CLASS TEXTBOX
IF PCOUNT() == 0
RETURN ::nValue
ELSEIF PCOUNT() == 1
::nCaseConvert := nValue
ENDIF
RETURN NIL
Code: Select all
METHOD ProcessTextChange( cText ) CLASS TEXTBOX
LOCAL icp, InBufferLeft, InBufferRight
HB_SYMBOL_UNUSED( cText )
IF ::lDateTextBoxActive
::lDateTextBoxActive := .F.
ELSE
icp := ::oQTObject:cursorPosition()
IF ::nCaseConvert>0
cText := IF(::nCaseConvert==1,UPPER(cText),LOWER(cText))
::oQTObject:setText( cText )
::oQTObject:setCursorPosition( icp )
ENDIF
IF ::nMaxLength>0
IF Len( cText ) > ::nMaxLength
InBufferLeft := Left( cText , icp )
InBufferRight := Right( cText , Len( cText ) - icp - 1 )
::oQTObject:setText( LEFT(InBufferLeft + InBufferRight,::nMaxLength) )
::oQTObject:setCursorPosition( icp )
ENDIF
ENDIF
IF Len( ::cInputMask ) > 0
IF ::cTextBoxType == 'MASKEDTEXT'
IF ::lMaskedFlag == .T.
Self:ProcessCharmask( .t. )
ENDIF
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ELSEIF ::cTextBoxType == 'CHARMASKTEXT'
Self:ProcessCharMask()
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ENDIF
ELSE
IF ::cTextBoxType == 'NUMTEXT'
Self:ProcessNumText()
ENDIF
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ENDIF
ENDIF
RETURN NIL
Samples:
Code: Select all
With Object oFriend := TextBox():New( "oFriend" )
:Row := 85
:Col := 15
:Width := 485
:Height := 20
:ToolTip := 'Name of the Friend'
:MaxLength := 50
:OnEnter := { || InsertTab() }
:CaseConvert := 1
End With
Re: Uppercase in textbox (HMG4)
It gives error with accented letters (ÁÉÃÕÇ)
Re: Uppercase in textbox (HMG4)
Hi Friends, problem resolved:
Code: Select all
METHOD ProcessTextChange( cText ) CLASS TEXTBOX
LOCAL icp, InBufferLeft, InBufferRight, InBuffer
HB_SYMBOL_UNUSED( cText )
IF ::lDateTextBoxActive
::lDateTextBoxActive := .F.
ELSE
icp := ::oQTObject:cursorPosition()
IF ::nCaseConvert>0
InBuffer := ::oQTObject:text()
InBuffer := IF(::nCaseConvert==1,UPPER(InBuffer),LOWER(InBuffer))
::oQTObject:setText( InBuffer )
::oQTObject:setCursorPosition( icp )
ENDIF
IF ::nMaxLength>0
InBuffer := ::oQTObject:text()
IF Len( InBuffer ) > ::nMaxLength
InBufferLeft := Left( InBuffer , icp )
InBufferRight := Right( InBuffer , Len( InBuffer ) - icp - 1 )
::oQTObject:setText( LEFT(InBufferLeft + InBufferRight,::nMaxLength) )
::oQTObject:setCursorPosition( icp )
ENDIF
ENDIF
IF Len( ::cInputMask ) > 0
IF ::cTextBoxType == 'MASKEDTEXT'
IF ::lMaskedFlag == .T.
Self:ProcessCharmask( .t. )
ENDIF
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ELSEIF ::cTextBoxType == 'CHARMASKTEXT'
Self:ProcessCharMask()
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ENDIF
ELSE
IF ::cTextBoxType == 'NUMTEXT'
Self:ProcessNumText()
ENDIF
IF ValType( ::bOnChange ) != 'U'
Eval( ::bOnChange )
ENDIF
ENDIF
ENDIF
RETURN NIL
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Uppercase in textbox (HMG4)
Nice work
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Uppercase in textbox (HMG4)
Code: Select all
METHOD MaxLength( nValue ) CLASS TEXTBOX IF PCOUNT() == 0 RETURN ::nValue ELSEIF PCOUNT() == 1 ::nMaxLength := nValue ENDIF RETURN NIL
Code: Select all
METHOD CASEConvert( nValue ) CLASS TEXTBOX IF PCOUNT() == 0 RETURN ::nValue ELSEIF PCOUNT() == 1 ::nCaseConvert := nValue ENDIF RETURN NIL
Sorry, but this code has an error in the RETURN ::nValue...
Re: Uppercase in textbox (HMG4)
Correct, it is true:
Sorry!
Code: Select all
METHOD CASEConvert( nValue ) CLASS TEXTBOX
IF PCOUNT() == 0
RETURN ::nCaseConvert
ELSEIF PCOUNT() == 1
::nCaseConvert := nValue
ENDIF
RETURN NIL
Code: Select all
METHOD MaxLength( nValue ) CLASS TEXTBOX
IF PCOUNT() == 0
RETURN ::nMaxLength
ELSEIF PCOUNT() == 1
::nMaxLength := nValue
ENDIF
RETURN NIL
Re: Uppercase in textbox (HMG4)
Patch commited to svn
please check
please check
Re: Uppercase in textbox (HMG4)
mrduck, need only change:
Thanks!
Code: Select all
DATA nMaxLength INIT 0
Re: Uppercase in textbox (HMG4)
pctoledo wrote:mrduck, need only change:
Thanks!Code: Select all
DATA nMaxLength INIT 0
done, sorry