I can't figure this out... When I pass a string that is in an object type to a function (in fidget) I get this error:
Error: type mismatch: got <type string>
I tried this on the playground, and got two times 'string' as result :
import typetraits
var myFolder: string
type
Configuration* = object
myFolder*: string
echo myFolder.type.name
echo Configuration.myFolder.type.name
But in my code all goes fine when I pass myFolder, but get the compiler error when I pass Configuration.myFolder while both are declared as string
C:\Users\Ivan\ReGUI_03a.nim(721, 9) template/generic instantiation of `group` from here C:\Users\Ivan\ReGUI_03a.nim(723, 10) template/generic instantiation of `text` from here C:\Users\Ivan\ReGUI_03a.nim(728, 15) template/generic instantiation of `binding` from here C:\Users\Ivan\.nimble\pkgs\fidget-0.7.8\fidget.nim(445, 16) Error: type mismatch: got <type string> but expected one of: proc characters(text: string) first type mismatch at position: 1 required type for text: string but expression 'Configuration.myFolder' is of type: type string expression: characters Configuration.myFolder
The offending code snippet :
proc guiSettings() =
group "input":
box 260, 15, 500, 30
text "text":
box 9, 8, 492, 25
fill "#46607e"
strokeWeight 1
font "IBM Plex Sans", 12, 200, 0, hLeft, vCenter
binding Configuration.myFolder
# binding myFolder
text "textPlaceholder":
box 9, 8, 492, 25
fill "#46607e", 0.5
strokeWeight 1
font "IBM Plex Sans", 12, 200, 0, hLeft, vCenter
if folder_reentry == "":
characters "Path to ReEntry data folder"
rectangle "bg":
box 0, 0, 500, 30
stroke "#72bdd0"
cornerRadius 5
strokeWeight 1
group "label":
box 150, 15, 100, 30
text "Text field:":
box 0, 0, 100, 30
fill "#46607e"
strokeWeight 1
font "IBM Plex Sans", 14, 200, 0, hLeft, vCenter
characters "ReEntry folder:"
The "binding" in fidget is a template which uses the proc characters :
template binding*(stringVariable: untyped) =
## Makes the current object text-editable and binds it to the stringVariable.
current.bindingSet = true
selectable true
editableText true
if not current.hasKeyboardFocus():
characters stringVariable
if not defined(js):
onClick:
keyboard.focus(current)
onClickOutside:
keyboard.unFocus(current)
onInput:
if stringVariable != keyboard.input:
stringVariable = keyboard.input
Is it the 'untyped' which causes this issue. Anyway, how do I resolve this ?
Yeah, of course... makes me feel a bit stupid I used the declaration instead of a variable
type
Configuration* = object
myFolder*: string
var
myFolder: string
config: Configuration
...
...
binding config.myFolder