Page 1 of 1

Dynamic Placeholder

Posted: Thu Feb 01, 2018 8:27 pm
by dominique
We want to use the Placeholder property instead a fieldlabel for mobile view. Unfortunately we can't set the placeholder value during the rezisizing process. Does anyone have an idea to solve it?

Code: Select all

Define_Com Class(#prim_acol<#prim_EVEF>) Name(#pFldFields)

Evtroutine Handling(#Com_owner.CreateInstance)
For Each(#Member) In(#Com_owner.ComponentMembers) Operation(*Instance_Of #prim_EVEF)

#pFldFields.Insert( #Member )

Endfor
Endroutine

Code: Select all

Evtroutine Handling(#Com_owner.DesignChanged) Design(#Design)
* If no design instance supplied, it must be the default "desktop" size
If (#Design *Is *null)
#Com_owner.SizeForDesktop
Else
If (#Design.Name = Mobile)
#Com_owner.SizeForMobile
Endif
Endif
Endroutine

Mthroutine Name(SizeForMobile)
#pFldFields<>.LabelPosition := None
#pFldFields<>.Height := 30
#pFldFields<>.MarginLeft := 0
#pFldFields<>.MarginTop := 50

For Each(#oFld) In(#pFldFields)
#oFld.placeholder := #oFld.LabelText
Endfor
Endroutine

Mthroutine Name(SizeForDesktop)
#pFldFields<>.LabelPosition := Left
#pFldFields<>.Height := 25
#pFldFields<>.MarginLeft := 150
#pFldFields<>.MarginTop := 0

* remove placeholder
#pFldFields<>.placeholder := *blanks
Endroutine

It's only possible to set the Placeholder during createInstance but not dynamic

Code: Select all

Evtroutine Handling(#Com_owner.CreateInstance)
For Each(#Member) In(#Com_owner.ComponentMembers) Operation(*Instance_Of #prim_EVEF)

#pFldFields.Insert( #Member )
#Member.placeholder := #Member.LabelText

Endfor
Endroutine


Re: Dynamic Placeholder

Posted: Fri Feb 02, 2018 1:57 pm
by dannyoorburg
Hi Domique,

I think you found a bug in Visual LANSA. Changing the place-holder doesn't trigger the Edit Box to update.

If you change another Edit Box related property, like AutoSelect, afterwards, the new place holder gets applied too.

Code: Select all

Evtroutine Handling(#Button1.Click)

#STD_TEXT.Placeholder := ""

* Dummy change to trigger update...
#STD_TEXT.AutoSelect := *Not #STD_TEXT.AutoSelect
#STD_TEXT.AutoSelect := *Not #STD_TEXT.AutoSelect

Endroutine
Cheers,
Danny