Antwort auf: Begrenzte Länge von Eingabefelder

Startseite Foren Deutsches LiveCode-Forum Begrenzte Länge von Eingabefelder Antwort auf: Begrenzte Länge von Eingabefelder

#14721
Herby
Teilnehmer

    Hallo Klaus,

    über die Länge der Feldnamen kann ich unterscheiden, in welches Feld eingegeben wird und die entsprechenden Eingabelängen der Felder begrenzen. Ich habe derzeit drei Felder (fdein (4), fdeinx (20), fdeinxy (20)).
    Die Routine arbeite ich im Startstack ab.
    Ich denke, dass bei einer keydown-target Abfrage eigentlich im Target der Feldname stehen müsste und nicht der Feldinhalt. Somit kann ich nur über the length of the target herausfinden, welches Feld gemeint ist.
    Ich denke dies ist ein LiveCode-Bug.

    Dein Vorschlag war schon richtig für die aktuelle Karte. Ich habe aber unterschiedliche Eingabelängen.
    Danke für dein Hilfe und Geduld
    herby

    Medizinische Lernkarten (Startstack)

    global xpfd — Programmpfad
    global xdsg — Datensätze gesamt
    global xdsa — Datensätze Abfragemenge
    global xakt — Datensatz aktuell (random)
    global xanz — Anzahl Abfragen
    global xwdm — Abfrage deutsch/medizin
    global xwal — Abfrage mit/ohne Abfrage
    global xw12 — Sortierung deutsch/medizin

    on OpenStack
    if the environment is „mobile“ then
    set the fullscreenmode of me to „exactFit“
    put specialFolderPath(„resources“) & „/Medizin.db“ into ppfd
    put specialFolderPath(„documents“) & „/Medizin.db“ into xpfd
    put specialFolderPath(„resources“) & „/Lernkarten.db“ into qpfd
    put specialFolderPath(„documents“) & „/Lernkarten.db“ into ypfd
    if there is NOT a file xpfd then
    put url(„binfile:“ & ppfd) into url(„binfile:“ & xpfd)
    put url(„binfile:“ & qpfd) into url(„binfile:“ & ypfd)
    end if
    else
    put specialfolderpath(„resources“) & „/Medizin.db“ into xpfd
    put specialfolderpath(„resources“) & „/Lernkarten.db“ into ypfd
    end if

    –Variablen initialisieren

    set the twelveHourTime to false
    UhrAnzeige
    Loeschen
    DSgesamt
    DSabfrage
    put xdsa into fld „fddid“ of card id 1002
    put 0 into xanz
    put xanz into fld „fdaba“ of card id 1002
    put true into xwdm
    set the label of btn „bnmod“ of card id 1027 to „Ein“
    put true into xwal
    set the label of btn „bneoz“ of card id 1027 to „Ein“
    put false into xw12
    set the label of btn „bn1o2“ of card id 1032 to „medizin“
    put „deutsch“ into fld „fdwdm“ of card id 1002
    end OpenStack

    on DSabfrage — xdsa Wieviele Datensätze ausgewählt ?
    put revOpenDatabase(„sqlite“,xpfd, , , , ) into xsql
    put „SELECT ID FROM DBMedizin WHERE Lernen = 1“ into xsel
    put revDataFromQuery(tab,return,xsql,xsel) into xerg
    if xerg = empty then
    put 0 into xdsa
    else
    put xerg into xdsa
    end if
    revCloseDatabase xsql
    end DSabfrage

    on DSgesamt — xdsg Gesamtanzahl der Datensätze
    put revOpenDatabase(„sqlite“,xpfd, , , , ) into xsql
    put „SELECT ID FROM DBMedizin“ into xsel
    put revDataFromQuery(tab,return,xsql,xsel) into xerg
    put the number of lines of xerg into xdsg
    revCloseDatabase xsql
    end DSgesamt

    on Loeschen — Anzeige löschen
    put 0 into xakt
    set the visible of btn „bnloe“ of card id 1002 to false
    put empty into fld „fdbeg“ of card id 1002
    put empty into fld „fdbes“ of card id 1002
    put empty into fld „fderk“ of card id 1002
    end Loeschen

    on hiliteChanged
    if the hilited of widget „SwB“ of card id 1027 then
    set the disabled of btn „bndbz“ of card id 1027 to false
    set the disabled of fld „fdein“ of card id 1027 to false
    else
    set the disabled of btn „bndbz“ of card id 1027 to true
    set the disabled of fld „fdein“ of card id 1027 to true
    end if
    end hiliteChanged

    on returnInField
    if fld „fdein“ of card id 1027 is a number then
    put fld „fdein“ of card id 1027 into fld „fdein“ of card id 1027
    end if
    if fld „fdeinx“ of card id 76194 then
    put fld „fdeinx“ of card id 76194 into fld „fdeinx“ of card id 76194
    end if
    if fld „fdeinxy“ of card id 76194 then
    put fld „fdeinxy“ of card id 76194 into fld „fdeinxy“ of card id 76194
    end if
    end returnInField

    on keydown xkey
    put the length of the target into x
    switch
    case x = 13
    if the length of the fld „fdein“ of card id 1027 < 4 then
    pass keydown
    end if
    break
    case x = 14
    if the length of the fld „fdeinx“ of card id 76194 < 20 then
    pass keydown
    end if
    break
    case x = 15
    if the length of the fld „fdeinxy“ of card id 76194 < 20 then
    pass keydown
    end if
    break
    end switch
    end keydown

    on UhrAnzeige
    put the time into fld „uhr“ of card id 1002
    send UhrAnzeige to this stack in 250 milliseconds
    end UhrAnzeige

    on closeStack
    quit
    end closeStack