Skip to content

Fix: Translation and Scale are not editable in Edit-layer dialog#182

Merged
ooxi merged 2 commits intogerbv:mainfrom
kitanokitsune:Fix-edit-layer-not-editable
Jul 9, 2023
Merged

Fix: Translation and Scale are not editable in Edit-layer dialog#182
ooxi merged 2 commits intogerbv:mainfrom
kitanokitsune:Fix-edit-layer-not-editable

Conversation

@kitanokitsune
Copy link
Copy Markdown
Contributor

gerbv.exe compiled by mingw-w64 with MSYS2 on Windows , in the Edit-layer dialog that opens by [Layer]-[Edit layer], numerical values cannot be entered into the edit box from the keyboard.

According to https://stackoverflow.com/questions/58318673/gtk-window-is-active-not-working-as-expected , the event handler which handles "focus-in-event" should return 0 or 1:

  • If the event handler returns 1 (TRUE), the behavior is handled by that event handler.
  • If the event handler returns 0 (FALSE), the behavior is GTK's default behavior.

Yet focus_in_event_callback does not return a value (void).

@ooxi
Copy link
Copy Markdown
Contributor

ooxi commented Jul 6, 2023

I cannot reproduce the issue, it's fine entering a value from the keyboard into layer translation and scale.

Nevertheless, I'm fine with changing the callback signature. But I cannot find any reference to it accepting int as return?

According to gtkd.org it should have a void return type?

@kitanokitsune
Copy link
Copy Markdown
Contributor Author

Thank you for comment.

Nevertheless, I'm fine with changing the callback signature. But I cannot find any reference to it accepting int as return?

According to gtkd.org it should have a void return type?

A certain source file on the web used int type, so I copied it.
However, in response to your comment, I have investigated again.
And I found some samples ([ _focus_in_cb ], [ GUI_ed1_cb1, GUI_ed1_cb2, GUI_ed1_cb3 ], [ Drag and drop example ]) which callbacks do not return void.

Indeed, the link you posted above also said the following:

This doesn't mean that all callback functions must take no parameters and return void.
The required signature of a callback function is determined by the context in which is used (e.g. the signal to which it is connected).

This means that the signature of the callback function seems to be context dependent.
In our case, the "focus-in-event" signal handler returns gboolean type. Therefore, it seems to me that the relevant code should have been modified as follows

gboolean
focus_in_event_callback (int *widget_num)
{
	focused_widget_num = *widget_num;
	return FALSE;
}

@ooxi ooxi merged commit 356cea4 into gerbv:main Jul 9, 2023
@ooxi
Copy link
Copy Markdown
Contributor

ooxi commented Jul 9, 2023

Thank you @kitanokitsune for all your work! It would be great if we can merge our efforts :-)

@kitanokitsune kitanokitsune deleted the Fix-edit-layer-not-editable branch August 24, 2023 13:25
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

Successfully merging this pull request may close these issues.

2 participants