Page MenuHome

File Browser: Add Ctrl+F shortcut to activate filter textbox

Authored by Jacques Lucke (JacquesLucke) on Feb 26 2020, 5:50 PM.



This patch adds a new FILE_OT_start_filter operator and a new ctrl+f shortcut.

It's fairly straight forward and based on TEXT_OT_start_find. The only difficulty
was to figure out, that I have to overwrite the context region temporarily to make it work.
Without this, the file browser would not receive any events anymore and appear frozen.
WM_event_add_ui_handler is eventually called by UI_textbutton_activate_rna and
expects C to reference the region that the activated uiBut is in.

Adding the User Interface team as reviewer, because this adds a new shortcut.

Diff Detail

rB Blender

Event Timeline

Rather than setting the context here, we could also do so through WM_OP_EXEC_REGION_UI, just like we have WM_OP_EXEC_REGION_CHANNELS and such.
@Campbell Barton (campbellbarton) do you agree?

This revision is now accepted and ready to land.Feb 26 2020, 9:28 PM

And while you're at it, maybe in the future you could make a patch that implements Ctrl+L to activate the file path textbox as well?
This is pretty standard on pretty much anything, file browsers/web browsers etc. And requested very often too:


@Julian Eisel (Severin) I'm not sure what you mean by that, can you elaborate?

@ThinkingPolygons (ThinkingPolygons) Sounds like a good idea. However, I never used that shortcut myself, so I cannot say how common it is. I'd rather have the UI team sign that off beforehand. Then it should be relatively easy to implement.

Hey @Jacques Lucke (JacquesLucke), I tested it and I love it! Really speeds up navigating in the File Browser. Thanks a lot!
I do agree with @ThinkingPolygons (ThinkingPolygons), CTR+L would be a nice addition indeed. It is quite a common shortcut, I would say. It works in the browser (e.g. Firefox) and, at least on Linux, in the File Browser as well. I use it quite a lot to avoid too much mouse movement.

Yes, +1.
Ctrl+L is the standard to activate the file path input field. 👍

Quickly talked to Brecht about this, we agreed that the context should actually be set somewhere within UI_textbutton_activate_rna() - you pass it the region, so the function should also make sure it correctly operates on that. Our suggestion would be to do it in ui_but_activate_event(), which should be the only code path executed through UI_textbutton_activate_rna() that depends on the active region.

  • Change context on ui_but_activate_event.

That sounds like a better solution to me.