2015-12-06 15:34:13

I didn't see any recent mention of it here, but now you can tailor Swift. big_smile

The most interesting part of this is that Apple is not using the Objective-C runtime for the foundation classes. That's a shame; it would have meant we'd get to see how to talk to it in the real Mac and iOS world. But a new programming language that promises fast code with a very enjoyable learning curve, open to the world, with what looks like solid portability on the way? Awesome!

Just myself, as usual.

2015-12-06 18:47:40

Have you seen the Objective-C runtime reference?  You can call into the Objective-C runtime from any C-capable language.  I think you can also make your own classes on the C side of things.  Someone has done it for at least Python--see PyObjC--but I'm not sure if this is the method they used and, unless VO can suddenly do indentation, you can't really do Python on a Mac anyway.  Still, it's possible and even documented.

My Blog
Twitter: @ajhicks1992

2015-12-06 23:05:00

There are bindings for the OBJC runtime, but so far all of the ones I've seen (including PyOBJC) still require that you build and link using an Objective-C thunk. I don't believe there's any binary-compatible way to do it from straight C a la COM, which I was rather hoping might arrive with Swift. The code for the runtime itself is out there, though, so maybe it's ultimately possible. The accessibility APIs themselves are of course part of the platforms, not Swift, so this is a purely academic observation: in practice there will be no more accessibility than is already being made available in Objective-C code today. That's a shame, but portability wins every time.

Just myself, as usual.

2015-12-07 02:17:51

You really need to skim this..  I'm 99.99% certain it's possible.  While the functions there are ill-documented, everything appears to be present, including class creation; I also recall seeing other guides on how to do it from back in the days when I cared and before I realized VO is crap for programming efficiently, but don't have links anymore.  It's certainly black magic, don't get me wrong, but I think it's doable.

My Blog
Twitter: @ajhicks1992

2015-12-07 16:18:21

Yeah, I've seen this. It's now mostly obsolete. Wonder why? smile

But my point here is that without any concerted effort to get Objective-C bridging easily accessible, our apps will not be getting any more accessible either (iOS or OS X). That's because toolkits are simply not going to adapt much further than subclassing views. Insisting that they import Objective-C or Swift to do that in portable code that's already largely in another toolkit just isn't feasible. See also this.

Just myself, as usual.

2015-12-08 00:04:55

I think accessibility on all platforms can be abstracted behind a library: acc_controlSetLable, acc_buttonSetClickHandler, etc.  In a lot of cases you can just redo your complicated control as ,one of the basic roles, and therefore it should arguably be doable.  COM has all the same problems.  COM is also technically doable from C, except that Microsoft actually has even less documentation on that than Apple does on calling ObjC in that manner.
Windows has support for virtual hierarchies.  I believe Linux does.  Presuming those functions still work, however, it looks like you can edit classes at runtime.  This of course raises many interesting questions, most of all whether or not you can actually add the accessibility-specific functions in.  But see here, especially the bit on UIAccessibilityContainer, and here's the Mac equivalent.  You can call into Objective-C from C using the same techniques you use to call into C++ from C.
Using OpenGL is becoming very common, no platform (including Android) fails to support this case.  Though what you have to do in Android is pretty awful.  If someone wanted to give me large sums of money, I'd start this project.  It's difficult but more than possible.  You just say "Do this to hook us in", and then provide a bunch of C functions.
But I've stopped caring.  Even Microsoft and Apple are failing to give us productive software.  It's not a tech problem, it's a social and economical one.  It's unsolvable outside the government stepping in.  There's no business case unless you need to target the school and university market.  I know that people love Apple [1], but being a productive coder inside XCode isn't possible, and all my audio friends still have to have Windows around.  And Microsoft is the same.  The only stuff that works fully is the stuff that everyone needs for college, step outside the world of the word processor and you hit the social wall.
As for Swift, I have yet to see any evidence of anyone caring outside iOS.  I'll care about Swift accessibility if and when Swift actually goes cross-platform and people start choosing.  The former has happened, but I see the latter as very unlikely for now.  Someone has to push it forward; it's not in the interest of Apple to push it forward.  Maybe Microsoft will pick it up.
1: I consider this irrational.  I strongly believe it could be experimentally proven that Windows is far more productive, but most people who love Apple are not objective, and so doing the test is basically impossible.

My Blog
Twitter: @ajhicks1992

2015-12-10 03:49:44 (edited by Ethin 2015-12-10 03:52:36)

@Camlorn, you can't make a portable accessibility library; it just isn't possible. To do so, you'd have to tap in to every accessibility API on the system, learn all the functions it uses, and then find a way to execute them. It's not like WXWidgets where it communicates with the OS for GUI components; we're talking about system-dependent accessibility APIs and screen-reader APIs. To make it work for the most amount of people, you'd have to make it work for every screen reader for maximum flexibility-something that is impossible. It just won't work on today's current technology architecture without extremely complicated workarounds. And if your going to try it, I'd recommend it in C++-C is rather verbose with function calls. Why not something like ac.SetControlCallback or ac.GetWindowTitle, rather than ac_GetWindowTitle? It seems better if you use OOP for organization.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2015-12-10 04:49:34

It would be smaller than Libaudioverse and all the accessibility APIs save Linux are fully, 100% documented.  The semantic meanings of all the basic controls are the same on all platforms.  It's just the facade pattern and then a bunch of testing.  It's not even a technical challenge, not really, just mind-numbingly boring and with a lot of tedium.
Basically you build a core model of accessibility for whatever you can support.  Button, combobox, checkbox, radiobutton, textrbox, slider, and maybe rich text are all doable.  You also implement the support for focusing controls that don't actually exist (this is what happens on the web, for example).  On top of that, you implement the platform specific interfaces for accessibility, which contain tons and tons of boilerplate (for Windows it's something like 300 or 400 lines).  These just read your platform-agnostic representation and return it, and sometimes raise events when the platform-agnostic version changes.
After that you write a manual documenting the best practices.  For example implement keyboard navigation and focus tracking (which does not come from the accessibility API unless you're on OSX).  And then you provide the platform-specific hooking samples.  On Windows this is "Put this code in the callback", on Mac it's "Have your root view inherit from this class or paste this chunk of code".  And that's it.  You've now made a cross-platform toolkit that can cover all the basic control types,.  If you need more than is covered, you open a ticket and we add one.  Or you implement it as more than one control and use the virtual hierarchy.  Or you map it to one of the controls that already exists.  There's a reason we don't get 50 new controls with every new OS: all the controls that people actually want already exist, and custom controls usually just do the same thing as one of them with a different look.
It's about a year of full-time work and probably fundable, once you've proven the concept.  I'm not the only one who thinks this is possible either: Matt Campbell from Serotek agrees with me that it could be done.
As for C versus C++?  yeah, it'd probably use C++ internally; nowadays, if you have to choose between the two it's best to always pick C++ in my opinion.  But if you want the library to be callable from any language but C++, you have to expose it to the external world with a C API.  There are Gui frameworks using OpenGL and only these controls in Python.  They exist in Rust.  Go.  Java.  C#.  Almost every language has OpenGL GUI frameworks, and almost every language has a fully capable C FFI.  You can wrap it behind something nicer if it's callable, but it needs to be callable first.  This is what libaudioverse does, you can make it work out very nicely with some macros or a program, or you can just take the hour or two to do it manually.  If you need C++ classes, you can later implement them on top of the C API; but if it's a library intended to be used from anything but C++, the C API needs to be the first and authoritative interface.
I don't consider this technically hard.  I consider this tedious and I'd never, ever do it for free because of the huge boredom factor.  But someone needs to, and it's on the queue of projects I want to do if I can get some money.  It's not actually different from WX at all, it's just going in the other direction (that is, instead of it calling the OS, the OS calls it).  I learn new APIs all the time for everything I do.  Adding 5 or 6 more is by no means impossible, though I will concede these are perhaps larger and less user-friendly than most.
As for the justification?  No one wants to add a few thousand lines to their GUI framework; no one tests it when they do.  This would centralize the effort.  If I did it, it would be centralized with a blind person in control.  If it existed, there is basically no doubt that people would use it; Kivy almost certainly would, for one.  In fact the reason I started thinking about this was because I was looking at doing Kivy accessibility.  The truth is, making a GUI framework accessible on all platforms takes literally exactly as much effort as writing this library; every time someone does it, they do exactly this, they just aren't separating the code into something reusable.

My Blog
Twitter: @ajhicks1992