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
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Front-end framework
by
PierceNg
[
Today
at 05:46:34 am]
Amigo programming languag...
by
paxscript
[
Today
at 05:21:56 am]
[SOLVED] The "dockedforme...
by
Gustavo 'Gus' Carreno
[
Today
at 05:08:22 am]
How many lines is too man...
by
440bx
[
Today
at 04:12:46 am]
X11Libre, finally and for...
by
Fred vS
[
Today
at 03:37:59 am]
https://live.freepascal.o...
by
PierceNg
[
Today
at 03:04:22 am]
Debian removes FPC/Lazaru...
by
Fred vS
[
Today
at 01:17:08 am]
PasLLM - LLM Inference En...
by
valdir.marcos
[
Today
at 01:11:25 am]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 01:09:53 am]
TDirectoryEdit with OnAft...
by
Bart
[
Today
at 01:04:32 am]
Problem wih reference to ...
by
PascalDragon
[
Today
at 12:09:44 am]
Win 11, strange position ...
by
Bart
[March 07, 2026, 11:23:38 pm]
Benchmark test in nanosec...
by
PascalDragon
[March 07, 2026, 11:14:15 pm]
How to execute a procedur...
by
n7800
[March 07, 2026, 10:17:32 pm]
Set horizontal scroll pos...
by
jamie
[March 07, 2026, 09:50:54 pm]
[SOLVED] Add Help to an A...
by
valdir.marcos
[March 07, 2026, 07:18:00 pm]
Variable initialization
by
valdir.marcos
[March 07, 2026, 05:58:47 pm]
Lazarus IDE built for LCL...
by
valdir.marcos
[March 07, 2026, 05:57:09 pm]
Status of LCL-fpGUI widge...
by
valdir.marcos
[March 07, 2026, 04:04:53 pm]
Status of LCL's CustomDra...
by
zeljko
[March 07, 2026, 03:59:56 pm]
uses unit decalration ord...
by
Martin_fr
[March 07, 2026, 02:10:32 pm]
Update a table with an Au...
by
CraigC
[March 07, 2026, 01:56:50 pm]
could Ardour's YTK be use...
by
robert rozee
[March 07, 2026, 01:51:39 pm]
[SOLVED] File Format LAMW...
by
RaketeMike
[March 07, 2026, 01:41:46 pm]
[ANN] PasBuild 1.5.0 rele...
by
cdbc
[March 07, 2026, 05:10:09 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [CLOSED] TEdit: & (Ampersand) gets deleted (Read 1790 times)
wittbo
Full Member
Posts: 152
[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 M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
lucamar
Hero Member
Posts: 4217
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: 13401
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: 152
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 M2 with MacOS 14.4.1 / Lazarus 3.2.2
MacStudio M1 Max with MacOS 14.4.1 / Lazarus 3.2.2
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Operating Systems
»
macOS / Mac OS X
»
[CLOSED] TEdit: & (Ampersand) gets deleted
TinyPortal
© 2005-2018