https://linen.dev logo
Join Discord
Powered by
# haxe-ui
  • u

    user

    06/04/2020, 12:59 PM
    I always avoid if possible this method
  • u

    user

    06/04/2020, 1:01 PM
    ok, easy fix (if text == reformatedText return;)
  • u

    user

    06/04/2020, 1:01 PM
    now I need to avoid lost of the caret
  • b

    bright-gpu-74537

    06/04/2020, 2:39 PM
    i wonder if some function here would be useful, "replaceText" or something like that... i mean, i can think of other times when you might want to change the text, not the caret and no get an event
  • b

    bright-gpu-74537

    06/04/2020, 2:39 PM
    ill see what you come up with first though, but once you have something it might be useful to have that in haxeui-core someway (and not just for restrictChars)
  • u

    user

    06/04/2020, 2:56 PM
    sure
  • u

    user

    06/04/2020, 2:56 PM
    I'm locked because insertionPoint isn't exposed
  • u

    user

    06/04/2020, 2:56 PM
    only on hxWidget side
  • b

    bright-gpu-74537

    06/04/2020, 3:01 PM
    ok, so for now, could you just use the
    .window
    of the component, its specific to haxeui-hxwidgets ofc
  • b

    bright-gpu-74537

    06/04/2020, 3:02 PM
    its a generic wxWindow, so you'll need to cast it to the the right type,
    cast(component.window, hx.widgets.TextCtrl)
    i think
  • u

    user

    06/04/2020, 3:29 PM
    he! it works 🙂
  • u

    user

    06/04/2020, 3:33 PM
    Copy code
    #if cpp
        function onValidRestrictedTF(e) {
            //'try' to handle cast exception
            try
            {
                if (tf.restrictChars == "") return;
                var formated:String ="";            
                var ip:Int = tf.text.length-1;
                var ff:Array<String> = tf.text.split("");
                for(c in ff)
                {
                    if ( tf.restrictChars.indexOf(c) >= 0  )
                        formated += c;
                    else
                        ip = tf.text.indexOf(c);
                }
                if (formated == tf.text)    return;
    
                tf.value = formated;
    
                var hxtcrl:TextCtrl = cast(tf.window, hx.widgets.TextCtrl);
                hxtcrl.insertionPoint = ip;
            }
            catch(e:Dynamic)
            {
    
            }
        }
    #end
  • u

    user

    06/04/2020, 3:33 PM
    Copy code
    #if cpp
            if (Backend.id == "hxwidgets")
            {
                tf.registerEvent(UIEvent.CHANGE, onValidRestrictedTF);
             }
    #end
  • u

    user

    06/04/2020, 3:34 PM
    I tried w/o success to use
  • u

    user

    06/04/2020, 3:34 PM
    Copy code
    var regexp:EReg = cast(tf.behaviours.find("restrictChars"), RestrictCharsBehaviour).regexp;
                if (regexp != null) {
                    formated = regexp.replace(tf.text, "");
                }
  • u

    user

    06/04/2020, 3:41 PM
    Tried to do the same for hint but hxTextCtrl doesn't expose it
  • b

    bright-gpu-74537

    06/04/2020, 3:41 PM
    > //'try' to handle cast exception
  • b

    bright-gpu-74537

    06/04/2020, 3:41 PM
    ?
  • u

    user

    06/04/2020, 3:41 PM
    I use try/catch for cast
  • b

    bright-gpu-74537

    06/04/2020, 3:41 PM
    sure, but why? I mean, whats the exception?
  • u

    user

    06/04/2020, 3:41 PM
    since there is no way to knwo if a cast was a failure or not
  • b

    bright-gpu-74537

    06/04/2020, 3:43 PM
    also, you could use an "unsafe" cast, eg:
  • b

    bright-gpu-74537

    06/04/2020, 3:43 PM
    Copy code
    var hxtcrl:TextCtrl = cast tf.window
    if (hxctrl != null) { ... }
  • u

    user

    06/04/2020, 3:44 PM
    hmmm
  • u

    user

    06/04/2020, 3:44 PM
    I read the haxe page about it and for some reasons, I didn't understand "unsafe" way
  • b

    bright-gpu-74537

    06/04/2020, 3:44 PM
    well, basically, i just means if cant cast it, it returns null rather than throws an exception
  • u

    user

    06/04/2020, 3:45 PM
    go for unsafe then
  • u

    user

    06/04/2020, 3:45 PM
    easier to maintain and read 😉
  • b

    bright-gpu-74537

    06/04/2020, 3:45 PM
    im not really a fan personally, i would prefer an exception, which is why i wondered what the exception is
  • b

    bright-yak-48460

    06/04/2020, 5:54 PM
    I have a ScrollView behavior proposition. It either entails conditional behavior modification to the current scrollModes or maybe just a new one.
1...263264265...1687Latest