Sign up

Pages: 1 2

Re: Using modifers to make things happen

bool keyPressCallback(Event ev, Widget w)

Hi, I can't find 'Event', what do I import for it. Thanks.

My program has been crashing the odd time lately, loosing text file data, (since putting in Control + S etc in it). So I hope this new way will fix that.

Re: Using modifers to make things happen

On 08/27/2013 02:04 AM, Joel Christensen wrote:

bool keyPressCallback(Event ev, Widget w)

Hi, I can't find 'Event', what do I import for it. Thanks.

My program has been crashing the odd time lately, loosing text file data, (since putting in Control + S etc in it). So I hope this new way will fix that.

It's in: gdk.Event

Re: Using modifers to make things happen

It's in: gdk.Event

Yay! It's working so far. Thanks Mike.

Re: Using modifers to make things happen

On Wed, 07 Aug 2013 21:38:45 GMT, Mike Wey wrote:

On Wed, 07 Aug 2013 20:58:52 GMT, Mike Wey wrote:

On Wed, 07 Aug 2013 01:08:13 GMT, Joel Christensen wrote:

Yay, it works. I can just hit control + S save my work, and not have to move the mouse at all. Though I used a dummy menu item, that was attached to the grid, but not shown. Is there a better way?

As far as i know the AccelGroup need to be associated with an menuItem to function properly.

This might also work: (i wasn't able to test it)

window.addOnKeyPress(&keyPressCallback);

bool keyPressCallback(Event ev, Widget w)
{
	if ( ev.key.keyval == GdkKeysyms.GDK_s
		&& ev.key.state == GdkModifierType.CONTROL_MASK )
	{
		//Do stuff.

		return true;
	}

	return false;
}

I haven't been using GtkD for a while.

I think this code crashes:

_grid.attach(new MenuItem((menuItem) { saveNotesCurrent(); },
		                          "_blar", "blar.blar", true, _accelGroup, 's',
		                          GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE),0,0,1,1);```

What is a better way to call functions with eg Control + S for save?

Re: Using modifers to make things happen

On Mon, 21 Jul 2014 23:49:30 GMT, Joel Christensen wrote:

On Wed, 07 Aug 2013 21:38:45 GMT, Mike Wey wrote:

On Wed, 07 Aug 2013 20:58:52 GMT, Mike Wey wrote:

On Wed, 07 Aug 2013 01:08:13 GMT, Joel Christensen wrote:

Yay, it works. I can just hit control + S save my work, and not have to move the mouse at all. Though I used a dummy menu item, that was attached to the grid, but not shown. Is there a better way?

As far as i know the AccelGroup need to be associated with an menuItem to function properly.

This might also work: (i wasn't able to test it)

window.addOnKeyPress(&keyPressCallback);

bool keyPressCallback(Event ev, Widget w)
{
	if ( ev.key.keyval == GdkKeysyms.GDK_s
		&& ev.key.state == GdkModifierType.CONTROL_MASK )
	{
		//Do stuff.

		return true;
	}

	return false;
}

I haven't been using GtkD for a while.

I think this code crashes:

_grid.attach(new MenuItem((menuItem) { saveNotesCurrent(); },
		                          "_blar", "blar.blar", true, _accelGroup, 's',
		                          GdkModifierType.CONTROL_MASK, GtkAccelFlags.VISIBLE),0,0,1,1);```

What is a better way to call functions with eg Control + S for save?

Oh, I think this is an old problem, I think it's fixed now.

Re: Using modifers to make things happen

On 07/22/2014 05:49 AM, Joel Christensen wrote:

Oh, I think this is an old problem, I think it's fixed now.

My work here is done ;)

Pages: 1 2