'Enables the user to change the value of a TextItem. Updates the item with the vew Value and returns TRUE if the Value was changed
public Sub ChangeTextItem(Item As PropertyEditorItem, Width As Int) As ResumableSub
Dim Changed As Boolean ' Return TRUE if selection changed, FALSE otherwise
'Setup custom panel
Dim PanelWidth As Int = Width - 16dip
Dim PanelHeight As Int = DipToCurrent(Min(100dip, Min(100%x, 100%y)))
Dim p As Panel
p.Initialize("pnlDialog")
p.SetLayoutAnimated(200, 1, 0, 0, PanelWidth, PanelHeight)
p.SetBorder(2dip, Colors.LightGray, 10)
Dim tv As TextView
tv.Initialize("")
tv.Font = Font.CreateNew(18)
tv.Text = Item.TextValue
AddCloseKeyboardView(tv)
p.AddView(tv, 8dip, 8dip, PanelWidth - 16dip, PanelHeight - 16dip)
'Setup/show the dialog
Dim d As CustomLayoutDialog
d.Initialize(p)
d.Style = d.STYLE_EDIT
Dim sf As Object = d.ShowAsync("Edit text", "Done", "Cancel", "", False)
MoveCustomDialog(d, 100) 'Move the dialog to the top of the display
Wait For (sf) Dialog_Result (dr As Int) 'Wait for then return result
Select dr
Case d.RESULT_POSITIVE
Dim NewValue As String = tv.Text
Changed = (NewValue <> Item.TextValue)
Item.TextValue = NewValue
Case Else
End Select
Return Changed
End Sub