Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
macOS / Mac OS X
»
[CLOSED] TEdit: & (Ampersand) gets deleted
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
JEDI error but unit compi...
by
DomingoGP
[
Today
at 09:27:06 pm]
Poll: Watches and Display...
by
Martin_fr
[
Today
at 09:22:47 pm]
Understanding and adjusti...
by
circular
[
Today
at 09:09:56 pm]
how to search in rxmemory...
by
rcmz
[
Today
at 08:45:16 pm]
Controlling the behavior ...
by
wp
[
Today
at 08:29:28 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[
Today
at 08:21:29 pm]
Dialog ShowModal and an i...
by
ASerge
[
Today
at 08:04:11 pm]
how to change the color f...
by
wp
[
Today
at 07:23:58 pm]
Dynarray initialization p...
by
Thaddy
[
Today
at 06:30:12 pm]
Project fails on run but ...
by
dseligo
[
Today
at 05:30:42 pm]
Zeos components. Had to c...
by
Fantablup
[
Today
at 04:17:13 pm]
[SOLVED] Completion box s...
by
furious programming
[
Today
at 04:12:26 pm]
[LAMW] How to create a ca...
by
af0815
[
Today
at 03:48:16 pm]
Complex package installat...
by
wp
[
Today
at 03:38:16 pm]
A "leisure" question on W...
by
gidesa
[
Today
at 03:17:10 pm]
Curling Pythagoras Tree: ...
by
AlexTP
[
Today
at 03:07:53 pm]
[SOLVED] Combined pointer...
by
CM630
[
Today
at 02:48:41 pm]
Using KeyPress event, how...
by
Zvoni
[
Today
at 02:24:42 pm]
a Unit problem?
by
Thaddy
[
Today
at 01:56:12 pm]
Any upgrades to fpWeb pag...
by
marcov
[
Today
at 12:50:25 pm]
Help needed with Cairo / ...
by
Roland57
[
Today
at 12:25:16 pm]
Configure JCF messages
by
DomingoGP
[
Today
at 11:26:55 am]
IDE instability on Raspbe...
by
rvk
[
Today
at 10:37:14 am]
Boleeman's projects are p...
by
AlexTP
[
Today
at 10:18:04 am]
Your best UI design - con...
by
circular
[
Today
at 09:36:11 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [CLOSED] TEdit: & (Ampersand) gets deleted (Read 1400 times)
wittbo
Full Member
Posts: 150
[CLOSED] TEdit: & (Ampersand) gets deleted
«
on:
February 14, 2020, 01:38:36 pm »
This morning I got a really enerving problem:
I want to edit a string, that contains some ampersand chars. My program code makes some declarations like:
s := 'example&name&surname'
edit1.text := s
Upon doing this, all ampersands get deleted and the text in the edit field is without any ampersands.
When i duplicate all ampersands before writing the string into the edit field:
s := 'example&&name&&surname'
all double ampersands are replaced by one single ampersand in the tedit field.
What could/should I do to realize a standard editing solution including strings with ampersand chars?
«
Last Edit: February 14, 2020, 02:58:47 pm by wittbo
»
Logged
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4
lucamar
Hero Member
Posts: 4219
Re: TEdit: & (Ampersand) gets deleted
«
Reply #1 on:
February 14, 2020, 02:22:18 pm »
Can't reproduce in Linux; it might be an OS dependent artifact or a bug that makes it process
Text
(which is a
TCaption
rather than a plain String, though it shouldn't matter) the same way it does for a labels, buttons, menu items, etc. where "
&
" is used to signal the "shortcut" letter in the caption (the one underlined).
A workaround to correct it is to code a specialized function to set the text for edit controls, something like:
Code: Pascal
[Select]
[+]
[-]
procedure
SetEditText
(
const
AnEdit
:
TEdit
;
const
Value
:
String
)
;
begin
if
Assigned
(
AnEdit
)
then
AnEdit
.
Text
:
=
StringReplace
(
Value
,
'&'
,
'&&'
,
[
rfReplaceAll
]
)
;
end
;
which you would use instead of assigning directly to
TEdit.Text
:
Code: Pascal
[Select]
[+]
[-]
{Instead of:
edit1.text := 'Tom & Jerry';
we'll do: }
SetEditText
(
Edit1
,
'Tom & Jerry'
)
;
Logged
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!)
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.
wp
Hero Member
Posts: 11857
Re: TEdit: & (Ampersand) gets deleted
«
Reply #2 on:
February 14, 2020, 02:57:27 pm »
Quote from: lucamar on February 14, 2020, 02:22:18 pm
Can't reproduce in Linux.
Can't reproduce on Windows either. Probably one more of there mysterious Mac bugs (if I interpret your signature correctly).
Logged
wittbo
Full Member
Posts: 150
Re: TEdit: & (Ampersand) gets deleted
«
Reply #3 on:
February 14, 2020, 02:57:41 pm »
It seems to be an artefact.
iMac 2011, macOS 10.13.6, Lazarus 2.0.2: Error occurs as described
MB Air 2014, macOS 10.14.6, Lazarus 2.0.6: works as expected, no error
So, maybe it's the macOS version or the Lazarus version.
I will close this defect.
Logged
-wittbo-
MBAir with MacOS 10.14.6 / Lazarus 2.2.4
MacStudio with MacOS 13.0.1 / Lazarus 2.2.4
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
macOS / Mac OS X
»
[CLOSED] TEdit: & (Ampersand) gets deleted
TinyPortal
© 2005-2018