Hi there Wix community,
I have made a wordle-type game for anatomy and it basically generates the emojis in string format for each guess.
I have concat this into text with linebreaks. I have then used copyToClipboard API to copy the text with line breaks when a button is pressed. But when you press the button on your iPhone (it actually makes you manually copy) and sometimes on Mac it doesn’t maintain the line breaks so what should look like this:
MUSCULOSKELORDLE
Sun May 15 2022
8/8
looks like:
MUSCULOSKELORDLE Sun May 15 2022 8/8
here is the code:
$w ( ‘#shareButtonMusculoskelordle’ ). onClick (()=> {
$w ( ‘#shareBoxMusculoskelordle’ ). text = ‘MUSCULOSKELORDLE \r\n’ + today . toDateString () + ‘\r\n’ + count + ‘/8’ + ‘\r\n’ + $w ( ‘#shareLine1’ ). value + ‘\r\n’ + $w ( ‘#shareLine2’ ). value + ‘\r\n’ + $w ( ‘#shareLine3’ ). value + ‘\r\n’ + $w ( ‘#shareLine4’ ). value + ‘\r\n’ + $w ( ‘#shareLine5’ ). value + ‘\r\n’ + $w ( ‘#shareLine6’ ). value + ‘\r\n’ + $w ( ‘#shareLine7’ ). value + ‘\r\n’ + $w ( ‘#shareLine8’ ). value
**let** shareMessage = $w ( '#shareBoxMusculoskelordle' ). text
wixWindow . copyToClipboard ( shareMessage )
. then ( () => {
// handle case where text was copied
$w ( '#shareButtonMusculoskelordle' ). label = 'copied to clipboard!'
} )
. **catch** ( ( err ) => {
// handle case where an error occurred
} );
})
I am wondering if people know how to create a share button to fix this while still using copyToClipboard, another workaround or simply a share button for social media with dynamic text input?
Thanks