Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help request: onchange of MultiLineEntry is never called #16

Closed
danielRi opened this issue Sep 10, 2024 · 6 comments
Closed

Help request: onchange of MultiLineEntry is never called #16

danielRi opened this issue Sep 10, 2024 · 6 comments

Comments

@danielRi
Copy link

danielRi commented Sep 10, 2024

Hi,

I´m fairly new to Nim and Uing. I started creating a text field, but I cant figure out why the onchanged function is never called, when I type something:

❯ nimble list -i      
nim  [(version: 2.0.8, checksum: 46333e8f4bda41dd6d3852a3f5fa4975b96b66a2)]
uing  [(version: 0.8.1, checksum: 92408d73d6e2e49e10c8d8d58aaaca63d0e85489)]
import uing

var 
  mainwin: Window
  mlEntry*: MultilineEntry
  mainhbox: Box

proc onChange(sender: MultilineEntry)

proc main =
  mainwin = newWindow("Parser", 640, 480)
  mlEntry = newMultilineEntry(onChange)
  mainhbox = newHorizontalBox()

  mainhbox.add(mlEntry)
  mainwin.child=mainhbox
  
  echo "starting..." # I see this output
  
  show mainwin
  mainLoop()

proc onChange(sender: MultilineEntry) =
  echo sender.text # I would expect this output when I type, but nothing happens

init()
main()

When I run this with

nimble run

I get a window with a multi line edit, everything looks good, however if I type in the text field, I cant see the echo output in the onChanged procedure (I do see the "starting..." output however). Im on a m1 macbook with macOs 14.5

Thanks a lot for any help!

@danielRi
Copy link
Author

Edit: If I add this line after I create the MultilineEntry:

mlEntry.onchanged = onChange

Then my callback gets called, however there is an error showing:

vehicle_parser_nim(96198,0x201018240) malloc: *** error for object 0x109757068: pointer being freed was not allocated
vehicle_parser_nim(96198,0x201018240) malloc: *** set a breakpoint in malloc_error_break to debug

@danielRi
Copy link
Author

danielRi commented Sep 10, 2024

another update:

I changed the code in the text proc in the uing.nim file. If I remove the free result line, it works. But its probably not what I want.  😄

proc text*(e: MultilineEntry): string = 
  ## Returns the multi line entry's text.
  ## 
  ## :e: MultilineEntry instance
  
  result = $multilineEntryText(e.impl)
  free result

@neroist
Copy link
Owner

neroist commented Sep 11, 2024

Does HEAD not work either? I believe I fixed the issue "pointer being freed was not allocated" already. Though I do need to look into the first one you mentioned.

@neroist
Copy link
Owner

neroist commented Sep 11, 2024

Please try using the most recent release 0.8.2! Both of these issues should be fixed.

@danielRi
Copy link
Author

danielRi commented Sep 12, 2024

Hey,
Thanks a lot for your time!
I upgraded uing to 0.8.2 and everything works as expected, like a charm.
Thanks again!

@neroist
Copy link
Owner

neroist commented Sep 15, 2024

🩷

@neroist neroist closed this as completed Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants