Page 2 of 2

Re: Preventing (text)button from being activated with enter

Posted: Wed Aug 12, 2015 9:26 am
by philat
I've never had reason to do it so I don't know off the top of my head. But I would assume that whatever you're using for the randomizer button is keying in on that text anyway?

Re: Preventing (text)button from being activated with enter

Posted: Wed Aug 12, 2015 9:36 am
by mobychan
I just save the random name in a variable and reload the screen, using the content of the variable as default ^^''

Re: Preventing (text)button from being activated with enter

Posted: Wed Aug 12, 2015 1:51 pm
by philat
Well, in that case isn't there no reason not to use use Return() without the If() part?

Re: Preventing (text)button from being activated with enter

Posted: Sat Aug 15, 2015 8:21 am
by mobychan
philat wrote:Well, in that case isn't there no reason not to use use Return() without the If() part?
You're right, it works^^
BUT I had to switch the order around, since it only works if the Key is defined AFTER the Random button^^

Thank you to all of you ^^

Re: [SOLVED] Prevent (text)button from being activated by en

Posted: Fri Aug 21, 2015 4:24 pm
by mobychan
After retesting I realised the "Return()" action won't return any inputted names, so I'm back to square one...

Basically I need a possibility to return the input's value in a custom keymapping

Re: [REOPEN] Prevent (text)button from being activated by en

Posted: Fri Aug 21, 2015 6:01 pm
by philat
I believe I ran a quick test on this last time, and the variable was stored in _return just fine from what I recall.

Re: [REOPEN] Prevent (text)button from being activated by en

Posted: Fri Aug 21, 2015 6:23 pm
by mobychan
if it reacts on the key

Code: Select all

key "K_RETURN" action Return()
I only get True in _return, even though I inserted something ^^''

my full screen:

Code: Select all

textbutton _("Random"):
        xpos 1018
        ypos 607
        background None
        text_style "ribbon_name_choosing_text_big"
        action [SetVariable("first_name", ""), 
                Return()]
        keyboard_focus False

    vbox:
        at ribbon_name_choosing_movein
        xpos 400
        ypos 510
            
        text "Please select a first name for the main character then press\nenter.":
            style "ribbon_name_choosing_text_big"
        
        input id "input_name":
            default first_name
            length 12
            style "ribbon_name_choosing_text_big"
        key "K_RETURN" action Return()
and I call it like this:

Code: Select all

    call screen ribbon_name_choosing("first_name_choosing")
    $ renpy.log("first: %s" % _return)
    if isinstance(_return, basestring):
        $ first_name = _return

Re: [REOPEN] Prevent (text)button from being activated by enter

Posted: Mon Jan 22, 2018 10:55 pm
by jesusalva
EDIT: You may want to look at viewtopic.php?f=51&t=38080#p412055 to don't need to use _return at all.

I used a couple of magic codes '-'
Would appreciate if someone used anti-magic on them >.>

Code: Select all

            ## Returns the input widget with ID 'input_name' on screen 'screen_name'. 
            textbutton "Submit" action Return(renpy.get_widget("screen_name","input_name"))
Remember to replace the textbutton with the key command (you only care about the action part)

And then, when handling the code, I use this magic code I've found out by coincidence while trying to use ui.input some time ago:

Code: Select all

    ## Gets second arg from Text() object
    $ _return=str(_return.text[1]) # This is magic, don't ask.
Purely magic, a hack, likely to break depending on version, but got the work done.
I have no idea why wrote this code, and I do not advice anyone using it.
But then, I was not working with commission, I was just writing code for fun, as a hobby... Just thought I would share it.