I want to make an imagebutton to copy a link instead of opening it. I searched and found CopyToClipboard(s) as an action but I couldn't make it work (also I don't understand what the "s" is for).
Also I'd like to add that function to the Quick Menu so people can report typos by copying the text and pasting it somewhere else. I don't know if I'll need the exact same thing as the one previously mentioned, so I'd like to know. Thanks for reading.
Bonus question: Maybe it's related to the last one so I'll post it here. Is it possible to save/store the last dialogue and display it when the player makes a save? I know that the game stores values and you can show them with things like %A, %d %b %Y, %H:%M, so maybe this is a thing. In theory, I guess it's already stored somewhere because the dialogue is displayed in the History screen, but I don't know if that applicable outside that screen.
[Solved]How to copy text with a button?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Adabelitoo
- Regular
- Posts: 93
- Joined: Sat Apr 13, 2019 2:32 pm
- Contact:
[Solved]How to copy text with a button?
Last edited by Adabelitoo on Mon Feb 05, 2024 3:40 am, edited 1 time in total.
- m_from_space
- Eileen-Class Veteran
- Posts: 1012
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: How to copy text with a button?
The "s" is the string you want to copy to the clipboard.Adabelitoo wrote: ↑Sun Feb 04, 2024 11:54 pm I want to make an imagebutton to copy a link instead of opening it. I searched and found CopyToClipboard(s) as an action but I couldn't make it work (also I don't understand what the "s" is for).
Code: Select all
imagebutton idle "myimage" action CopyToClipboard("http://lemmasoft.renai.us")
Yes, it's the same thing. If you make this specific button to report typos part of the say screen, you can just use the "what" variable (which is the spoken text at that moment) and copy it.Also I'd like to add that function to the Quick Menu so people can report typos by copying the text and pasting it somewhere else. I don't know if I'll need the exact same thing as the one previously mentioned, so I'd like to know. Thanks for reading.
Code: Select all
screen say(who, what):
...
textbutton "Report Dialogue Line" action CopyToClipboard(what)
The history screen just displays all saved dialogue that is within the variable "_history_list". So you just can extract the last spoken line of dialogue from the list in a similar way the history screen does. And then just save it inside a global variable. Or do you want to show this last line inside the save slots? Then you have to save it as part of save data, by adding it to the json dictionary I believe. https://www.renpy.org/dev-doc/html/conf ... _callbacksBonus question: Maybe it's related to the last one so I'll post it here. Is it possible to save/store the last dialogue and display it when the player makes a save? I know that the game stores values and you can show them with things like %A, %d %b %Y, %H:%M, so maybe this is a thing. In theory, I guess it's already stored somewhere because the dialogue is displayed in the History screen, but I don't know if that applicable outside that screen.
But here is a way to get the last line in general:
Code: Select all
screen last_spoken_line():
if _history_list:
$ last_entry = _history_list[-1]
$ last_line = renpy.filter_text_tags(last_entry.what, allow=gui.history_allow_tags)
text last_line
else:
text "There is no last line."
- Adabelitoo
- Regular
- Posts: 93
- Joined: Sat Apr 13, 2019 2:32 pm
- Contact:
Re: How to copy text with a button?
Thanks for replying.
I thought that was the case but it didn't work. I even copy-pasted your code but I get NameError: name 'CopyToClipboard' is not definedm_from_space wrote: ↑Mon Feb 05, 2024 3:00 am The "s" is the string you want to copy to the clipboard.
- m_from_space
- Eileen-Class Veteran
- Posts: 1012
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: How to copy text with a button?
You have to use Renpy 7.7 or 8.2 for that. It's a new function.Adabelitoo wrote: ↑Mon Feb 05, 2024 3:15 am Thanks for replying.
I thought that was the case but it didn't work. I even copy-pasted your code but I get NameError: name 'CopyToClipboard' is not definedm_from_space wrote: ↑Mon Feb 05, 2024 3:00 am The "s" is the string you want to copy to the clipboard.
- Adabelitoo
- Regular
- Posts: 93
- Joined: Sat Apr 13, 2019 2:32 pm
- Contact:
Re: How to copy text with a button?
I had 8.1 so I thought the version wouldn't be an issue, now it works. Thank you for everything.m_from_space wrote: ↑Mon Feb 05, 2024 3:32 am You have to use Renpy 7.7 or 8.2 for that. It's a new function.
Who is online
Users browsing this forum: Bing [Bot]