These are chat archives for AvaloniaUI/Avalonia

30th
Apr 2017
Jeremy Koritzinsky
@jkoritzinsky
Apr 30 2017 03:19
@grokys I pushed some updates for one of my PRs. I also went into our Codecov settings and tried to turn off the PR checks. I think I got it working (i.e. not checking PRs), but it's difficult to tell since our CI builds are broken.
Eli Arbel
@aelij
Apr 30 2017 06:12
@grokys Thanks :)
Nikita Tsukanov
@kekekeks
Apr 30 2017 07:07
Builds are fine
It's tests that aren't passing
Eli Arbel
@aelij
Apr 30 2017 08:24
Is there a way of getting a PreviewKeyDown event? I see there are tunneling events, just not this one.
danwalmsley
@danwalmsley
Apr 30 2017 09:22
@aelij no previewkey events
are implemented
In the editor for avalonstudio I had to tunnel the events to get them first
Eli Arbel
@aelij
Apr 30 2017 09:24
There's a small issue since KeyBindings are always processed first, so there's no way of marking an event as handled before key bindings are processed
key bindings like ctrl + c for example?
Eli Arbel
@aelij
Apr 30 2017 09:26
Yes
danwalmsley
@danwalmsley
Apr 30 2017 09:27
are you using KeyGesture class?
Eli Arbel
@aelij
Apr 30 2017 09:28
Yes, I've implemented RoutedCommands since AvalonEdit extensively used them. There's a command with key binding to <kbd>Enter</kbd>, which needs to be handled by the completion popup.
Hmm, I can see there's a way to handle events directly from the InputManager. Perhaps if I manage to subscribe before the KeyboardDevice, I can fire PreviewKey events.
danwalmsley
@danwalmsley
Apr 30 2017 09:32
It looks like I processed these on key down, and didnt have any problems
Eli Arbel
@aelij
Apr 30 2017 09:34
Are you using gestures?
danwalmsley
@danwalmsley
Apr 30 2017 09:35
a few like ctrl + s ctrl + c
If key gesture gets handled first what's the problem
Eli Arbel
@aelij
Apr 30 2017 09:39
I don't want Enter to be processed by the editor
Since key bindings are processed before the event is even fired, there's no way of stopping their processing
danwalmsley
@danwalmsley
Apr 30 2017 09:46
But my popup was able to handle enter key
Oh right this is how o did it
My popup was just visual display
I had an intelisense manager on the esitor
And that gets the keys before the editor
So popup never got real focus
From keyboard and then used a class on the editor
To subscribe to key events before the editor and relay them to the intellisense manager which handles the state of the popup
Eli Arbel
@aelij
Apr 30 2017 09:54
The popup is not the problem. It's unfocused in AvalonEdit as well. The editor itself has a lot of key bindings - they drive the entire editing experience. There's one for "Enter" and "Up" and "PageDown" keys (take a look here for example). And key bindings are always processed before the KeyDown event, so there's no place to mark such events as handled.
Your editor probably doesn't use key bindings to process caret navigation
Perhaps I should stop using key bindings at all. I wanted to avoid a complete rewrite of the "TextAreaInputHandler" so migration would be easy.
Eli Arbel
@aelij
Apr 30 2017 10:09

@grokys Maybe we could move KeyBinding processing to the input element itself? The base method could be something like:

protected virtual void OnKeyDown(KeyEventArgs e)
{
     if (e.Route == RoutingStrategies.Bubble)
        foreach (var binding in KeyBinding)
    {
        if(ev.Handled)
            break;
        binding.TryHandle(ev);
    }
}

Then each element could override and run code before calling the base, and possibly stop key binding processing.

danwalmsley
@danwalmsley
Apr 30 2017 10:15
If you do re-write the textarea handler
Then this code here does all those things and is compatible with avalonedit already....
Eli Arbel
@aelij
Apr 30 2017 10:18
Not sure I get your meaning
Eli Arbel
@aelij
Apr 30 2017 10:19
Oh
:) Should've waited
danwalmsley
@danwalmsley
Apr 30 2017 10:19
This is very similar to how the textbox handles these things
But adapted to work on avalonedits textdocument class
Eli Arbel
@aelij
Apr 30 2017 10:20
Yeah, but this remove the "TextAreaInputHandler" abstraction layer, which I wouldn't want to do.
I want to make it easy for people who customized it to migrate to Avalonia
danwalmsley
@danwalmsley
Apr 30 2017 10:21
I see
Perhaps then for now until a fix can be made to avalonia
Handle the enter key without using keybindings
And you can have your completions working
Eli Arbel
@aelij
Apr 30 2017 10:22
Yeah, that what I'll do probably
danwalmsley
@danwalmsley
Apr 30 2017 10:23
And then fix it once avalonia nightly builds are coming through again
Btw your popup
Are you also implementing a signature helper popup too?
Eli Arbel
@aelij
Apr 30 2017 10:23
Stephen's advice helped, the popup works now
danwalmsley
@danwalmsley
Apr 30 2017 10:24
That's good
Eli Arbel
@aelij
Apr 30 2017 10:24
Sure
It's called InsightsWindow
danwalmsley
@danwalmsley
Apr 30 2017 10:24
I'm not sure how avalonedit codd completion works but does it abstract the logic of when to trigger completion searches and which keys complete etc?
Eli Arbel
@aelij
Apr 30 2017 10:25
No, you have to do that yourself
Roslyn has logic for this, which I'm using
See the IsTriggerCharacter calls from ISignatureHelpProvider
If you look at the VS intellisense implementation (also open sourced on the Roslyn repo) you'll see it's much more complex. They have special handling for keys and lots of other specific scenarios, which make VS such a great editor. But this is good enough for my simple needs.
Eli Arbel
@aelij
Apr 30 2017 10:30
I once had a crazy thought of reimplementing the VS editor's interface using AvalonEdit and using the code as is (it's all in the Roslyn EditorFeature's assembly), but it was way too much work :)
danwalmsley
@danwalmsley
Apr 30 2017 10:52
Yeah that would be a lot of work
The intelisense logic in Avalon studio has been completely re-written about 4 times!
Its definitely not so easy to match what visual studio does
Steven Kirk
@grokys
Apr 30 2017 10:55
@kekekeks i fixed the tests in AvaloniaUI/Avalonia#968 but the build is still hanging
@aelij ok i've tried to follow the conversation, but i still don't understand what's missing from avalonia in terms of keyboard handling
Eli Arbel
@aelij
Apr 30 2017 10:59
You can't mark a key down event as handled before KeyBindings are processed. So there's no way to stop their processing.
What I'm suggesting is moving their processing from KeyboardDevice to InputElement so an overriding method could have full control.
Steven Kirk
@grokys
Apr 30 2017 11:04
ah ok, yes that would make sense
@kekekeks you wrote KeyBinding - does that make sense to you?
Eli Arbel
@aelij
Apr 30 2017 11:07
BTW, the WPF implementation is a bit different. It fires the tunneling event, then fires key bindings, then the bubbling event. If you handle the tunneling event, the rest of the chain stops.
In Avalonia the key tunneling and bubbling event are united into one, so this won't work.
Steven Kirk
@grokys
Apr 30 2017 11:08
but yes i agreee, key bindings shouldn't be "baked in" to the input handler - they should use the same methods of accessing events as everything else
oh really? so there's special handling of key events in that sense in WPF?
Eli Arbel
@aelij
Apr 30 2017 11:09
Yeah, the input handler is aware of key and command bindings. But eventually it's delegated to UIElement anyhow.
Steven Kirk
@grokys
Apr 30 2017 11:10
are you sure that the key binding handler isn't just the first handler of bubbling events in WPF?
Eli Arbel
@aelij
Apr 30 2017 11:11
Yes, I'm looking at the code right now.
private static void OnKeyDownThunk(object sender, KeyEventArgs e)
{
    Invariant.Assert(!e.Handled, "Unexpected: Event has already been handled.");
    CommandManager.TranslateInput((IInputElement)sender, e);
    if (!e.Handled)
    {
        UIElement uIElement = sender as UIElement;
        if (uIElement != null)
        {
            uIElement.OnKeyDown(e);
            return;
        }
CommandManager.TranslateInput is what fires key and command bindings
Steven Kirk
@grokys
Apr 30 2017 11:12
if that's the case, then i guess the key binding handler should insert itself as a RouteFinished handler: https://github.com/AvaloniaUI/Avalonia/blob/71194642063db397558c7df82b6c82f717ac6e39/src/Avalonia.Interactivity/RoutedEvent.cs#L66
Eli Arbel
@aelij
Apr 30 2017 11:13
Oh, that could work as well
Does this fire if the event is handled?
Steven Kirk
@grokys
Apr 30 2017 11:14
yeah, it should do
Eli Arbel
@aelij
Apr 30 2017 11:14
Oh, then that's not good. I need a way to cancel bindings.
Steven Kirk
@grokys
Apr 30 2017 11:15
the key binding handler would just do nothing if e.Handled == true
Eli Arbel
@aelij
Apr 30 2017 11:16
Okay, but you should know that the semantics would be slightly different than WPF in this case. The order should be PreviewKeyDown > KeyBindings > KeyDown
Steven Kirk
@grokys
Apr 30 2017 11:17
yep, that could be the same. the key binding handler listens for the end of the tunnel route, checks if the event is not handled and does its thing
Eli Arbel
@aelij
Apr 30 2017 11:18
Oh, the end of the tunnel route. Yeah, that work be the same way.
The way I proposed leaves the control in the hands of the dev. They can call base.OnKeyDown whenever they want in the overriding method. It's the same as Button.OnClick which calls ICommand.Execute
Steven Kirk
@grokys
Apr 30 2017 11:20
ah yeah that could work too
Eli Arbel
@aelij
Apr 30 2017 11:20
Anyway I worked around that for the time being by invoking the bindings myself
Steven Kirk
@grokys
Apr 30 2017 11:20
however in WPF, OnKeyDownThunk seems to just be a regular event handler: http://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/Windows/Generated/UIElement.cs,849
so it looks to me like it's just the first KeyDown handler, no special logic at all
Eli Arbel
@aelij
Apr 30 2017 11:23
Yes. It's just guaranteed to fir first because it uses RegisterClassHandler
Steven Kirk
@grokys
Apr 30 2017 11:26
right, so we can do that easily in avalonia, we don't even need to use RouteFinished
btw i have a fix incoming for handling non-Controls in the devtools
Eli Arbel
@aelij
Apr 30 2017 11:31
Cool
How often is myget updated?
Steven Kirk
@grokys
Apr 30 2017 11:34
it should be updated on every push to master but builds are broken currently because of this bug https://bugzilla.xamarin.com/show_bug.cgi?id=54467 which is causing builds to take >1 hour and meaning they time out
moving to VS2017/.net standard has been a disaster :(
Eli Arbel
@aelij
Apr 30 2017 11:35
I love the new project system but it does feel half baked at times
Managed to get completion working!
Steven Kirk
@grokys
Apr 30 2017 11:36
nice!!
Eli Arbel
@aelij
Apr 30 2017 11:37
This project is so cool :) What motivated you to start it?
Steven Kirk
@grokys
Apr 30 2017 11:37
i'm wondering whether to change the style key behavior to that of WPF where you need to specify a style key each time you create a new control
i originally started trying to reverse engineer WPF but that wasn't much fun, so i decided to just see how far i got with writing my own framework
quite far it turns out! a lot further than i expected
Eli Arbel
@aelij
Apr 30 2017 11:39
It's amazing what a bunch of people can build in their free time
whether to change the style key behavior
I've thought about it, and I think the current approach is better. Most of the times when you inherit from a control you want it to have a different template. It can be a small hurdle for someone coming from WPF, but this can be mitigated by maintaining a wiki page for such differences.
maybe we should have a default template for controls that don't have a template (maybe just in debug mode if possible?) that says "No template" or something?
Eli Arbel
@aelij
Apr 30 2017 11:46
You mean in VS? Yeah, that could be nice. I haven't installed the VS extension btw. I'm using to visualizing XAML in my head ;)
BTW, is anyone coming to Build next month? I'll be there
Steven Kirk
@grokys
Apr 30 2017 11:49
unfortunately not - i may be doing a talk on avalonia at .net fringe if it's accepted though
Steven Kirk
@grokys
Apr 30 2017 14:13
ah, appveyor looks like it's building again now
Steven Kirk
@grokys
Apr 30 2017 14:19
oh no, it's not :(
Eli Arbel
@aelij
Apr 30 2017 14:21
I have a very weird data binding issue. In the completion list, the ListBox.Items is set to an observable collection. When you type something, the list is filtered by assigning the Items property again. But no matter what's in the collection, the ListBox always shows the items from the original list (but the item count is the same as the new list). For example, if the original list had {A,B,C} and the new list is {C,D}, it would show {A,B}. It wouldn't repro using a regular ListBox. Voodoo :grin:
Steven Kirk
@grokys
Apr 30 2017 14:24
hmm i've heard of something similar happening
ah yeah someone submitted a PR demonstrating it: AvaloniaUI/Avalonia#887
i still havent' had chance to investigate
Eli Arbel
@aelij
Apr 30 2017 14:26
I'll give it a try
Steven Kirk
@grokys
Apr 30 2017 14:26
does that look like the same issue?
the PR is just a unit test - doesn't actually fix the issue
Eli Arbel
@aelij
Apr 30 2017 14:28
Yeah, does seem very similar
I suspected virtualization but my list only has 3 items. Perhaps during container recycling the data context is not properly set?
Steven Kirk
@grokys
Apr 30 2017 14:39
aha! the workaround in appveyor/ci#1479 seems to fix appveyor
Eli Arbel
@aelij
Apr 30 2017 14:46
:cool:
Nikita Tsukanov
@kekekeks
Apr 30 2017 15:37
@grokys
error CS0649: Field 'WicBitmapImpl._direct2D' is never assigned to, and will always have its default value null [C:\projects\Avalonia\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj]
I guess that's why build is failing
Also
RenderTarget.cs(10,43): error CS0535: 'RenderTarget' does not implement interface member 'IRenderTarget.CreateDrawingContext(IVisualBrushRenderer)' [C:\projects\Avalonia\src\Skia\Avalonia.Skia.iOS\Avalonia.Skia.iOS.csproj]
It looks like that you haven't changed mobile-specific render targets or something
Nikita Tsukanov
@kekekeks
Apr 30 2017 16:01
@grokys I've fixed the build
But now some skia-related tests are failing
Some of them are failing even on my local machine
Seems to be broken by removal of Canvas.Clear call or something
Is that OK to do?
Build is mostly fixed
Some leak tests are still failing
I can't reproduce it on my local machine
danwalmsley
@danwalmsley
Apr 30 2017 16:41
I have a very weird data binding issue. In the completion list, the ListBox.Items is set to an observable collection. When you type something, the list is filtered by assigning the Items property again. But no matter what's in the collection, the ListBox always shows the items from the original list (but the item count is the same as the new list). For example, if the original list had {A,B,C} and the new list is {C,D}, it would show {A,B}. It wouldn't repro using a regular ListBox. Voodoo :grin:
I have a work around for this!
I had exactly the same thing!
so basically here
I dispatch to ui thread (even if I was on the ui thread, for it to get processed on the next processing loop)
and I set the items to null
then to the new reduced set
this will make it work
but it does need fixing in avalonia
Eli Arbel
@aelij
Apr 30 2017 17:03
@danwalmsley You're the man :) Thanks
danwalmsley
@danwalmsley
Apr 30 2017 17:03
did it work?
Eli Arbel
@aelij
Apr 30 2017 17:03
Trying now
danwalmsley
@danwalmsley
Apr 30 2017 17:03
took me hours to find that "Hack"
im reviewing your pr in a minute, just got the build scripts sorted out
Eli Arbel
@aelij
Apr 30 2017 17:07
Yes, it works even w/o dispatching
danwalmsley
@danwalmsley
Apr 30 2017 17:07
woohoo!
Eli Arbel
@aelij
Apr 30 2017 17:07
:)
But we should really fix this bug
danwalmsley
@danwalmsley
Apr 30 2017 17:08
yes
because there are others too
im sure you will notice when you start to use it more
ocassionally it will filter
but the item in the listbox on the screen
isnt what is actually represetned
so you complete
and it completes with a different word
you need lots of data to repro it
Eli Arbel
@aelij
Apr 30 2017 17:12
I'll try when I hook up Roslyn
Nikita Tsukanov
@kekekeks
Apr 30 2017 17:56
It seems that Windows 10 Mobile will be discontinued
Not supporting UWP was probably the right choice
Eli Arbel
@aelij
Apr 30 2017 18:00
UWP has some advantages on the desktop though. Although I guess now with the Desktop Bridge it's not that big a difference.
Steven Kirk
@grokys
Apr 30 2017 18:25
@kekekeks thanks for fixing those, i had to run off but i'll try and get everything running again tomorrow
Steven Kirk
@grokys
Apr 30 2017 19:11
Regarding clearing when creating a drawing context, that messes with deferred rendering
Nikita Tsukanov
@kekekeks
Apr 30 2017 19:52
So we need to move clearing to ctor
Mkay
Makes sense
danwalmsley
@danwalmsley
Apr 30 2017 22:47
@kekekeks @grokys im setting up the avaloniaedit to publish to myget
can I use the same feed as you use for avalonia?